Also...certain grad students don't have FICA withheld....so it's not a 100% test....but "an indication".
In any event, I discussed this with an IRS agent a few years ago. According to this agent, when they return home they have to "fill out something...which I forget the name"....and if their papers aren't in order (1040-NRs not filed) they aren't allowed to leave. However, I never got a referral for an emergency 1040-NR so the person could leave the country.
But...from my experience I can tell you one thing that I have seen happen:
Indians on J-1s are tax exempt if their stay is under 2 years. However, if they decide to stay longer (one day past 2 years!) they have to pay back the exempted tax. I've very often amended the returns, so, all is good and legal.
However, many "just take the chance and leave it". Sometimes the IRS catches it; more often not. And they all tell me..."My friend didn't..etc...etc"
I know one husband/wife team. Wife got caught and had to pay back. Husband, no, they never questioned him.
I have a current client from Greece. She came here on a J-1 to work at Standford (the university should have known better) and her contract said that she was exempt from Federal tax for 5 years. Unfortunately Stanford was wrong. (And this was a legal document that had gone thru Standford's legal dept.) The treaty with Greece (which is crystal clear) says if you extend your stay past 3 years you need to pay back all the tax. The husband was never questioned. Not only that, the husband said that he had loads of Greek friends on J-1s at Stanford, all of them not paying tax for 5 years.
The wife questioned the IRS...and why the "audited her". The auditor said that they picked up on her because she put down her visa change (to H1- on her (self-prepared) 1040-NR. I told the husband Stanford should at least pick up the penalties & interest...but he didn't want to get into that because they wanted good references for jobs.
So...to answer the original question....from personal experience, lots of non-resident aliens file 1040s and get away with it. Lots of non-resident aliens stay longer than their "treaty exempt" period and get away with it. Lots of non-resident aliens are mis-advised by their institutions and get away with it (although they don't know that they're doing anything wrong).
And people wonder why I "question the knowledge of those in authority".