How can I test if a .tex file is portable?

The environmental variable TEXMFHOME is used to tell your TeX system where the 'personal' tree is. For TeX Live, this variable is not usually set and is derived from texmf.cnf, which will lead to it pointing to %USERPROFILE%\texmf on Windows, ~/texmf on Linux and ~/Library/texmf on a Mac. (For MiKTeX there is no 'out of the box' setting so it has to be created by hand.) However, once TEXMFHOME is set to some non-empty value it determines where is checked. So setting

TEXMFHOME=.

as appropriate for your operating system will stop searching of the personal tree. Do that before running TeX (say at the command line or in a script) and you'll cut off any local additions.

Even more 'definite' is to set TEXINPUTS=., which restricts all searching to just the current directory. That can be used if you have a 'truly' isolated set up, though perhaps is overkill for most people. (We use that for testing the LaTeX kernel, where all TeX files really do have to be from the current location.) More on TEXINPUTs is available in Definition of the TEXINPUTS variable. Also see http://tug.org/texlive/doc/texlive-en/texlive-en.html for the full docs on how searching works.