It requires a close examination of doctrine and fruit. Throughout the New Testament there are exhortations to hold fast to the truth and the teaching (doctrine). Jesus also said, "You will know them by their fruit."
There are many kinds of fruit noted in the New Testament letters: Fruit of righteousness (long-term change), fruit of repentance (sincerity and humility before God and His word), fruit of the Holy Spirit (immediate fruit of their typical temperament), fruit of giving (like Jesus' heart was towards others), fruit of good work (doing good and helping others).
Both of these things need to be examined at length before we can really know if they're functioning in the Holy Spirit or another spirit.
We should not automatically presume someone is functioning in the Holy Spirit just because they wow you with some supernatural act. In fact, Jesus warned that there would be lying signs and wonders right before His return.
The real issue the modern church is in is that it has completely disregarded these clear expectations for such supernatural activity, and it has done so to its own peril.
I sat in at a small-group once and could see a spirit hop around from person to person prophesying things that no one could know unless they were following me around. It was startling at first, because I presumed it must have been the Holy Spirit, but looking at the doctrine of these people and their fruit proved they were not functioning in the Holy Spirit whatsoever. They did not love the truth, but they loved the supernatural.