openmopac / mopac

Molecular Orbital PACkage
http://openmopac.net
GNU Lesser General Public License v3.0
122 stars 32 forks source link

All tests fail with shutil.SameFileError #120

Closed ntBre closed 2 years ago

ntBre commented 2 years ago

Describe the bug

After cloning the repo, running cmake ., make mopac, and make test, all of the tests fail with output like:

Start testing: Oct 05 08:15 EDT
----------------------------------------------------------
1/114 Testing: port
1/114 Test: port
Command: "/usr/bin/python3.10" "/home/brent/Projects/mopac/tests/run_test.py" "/home/brent/Projects/mopac/tests" "/hom
e/brent/Projects/mopac/mopac" "port.mop" "port.parameters" "try.txt" "aa.txt" "mol.in" "SETUP"
Directory: /home/brent/Projects/mopac/tests
"port" start time: Oct 05 08:15 EDT

Output:
----------------------------------------------------------
Traceback (most recent call last):
  File "/home/brent/Projects/mopac/tests/run_test.py", line 13, in <module>
    copyfile(os.path.join(argv[1],file),file)
  File "/usr/lib/python3.10/shutil.py", line 234, in copyfile
    raise SameFileError("{!r} and {!r} are the same file".format(src, dst))
shutil.SameFileError: '/home/brent/Projects/mopac/tests/port.mop' and 'port.mop' are the same file
<end of output>

Apologies in advance if this is just an issue with my setup, or where I'm running the tests. Wrapping the copyfile call in a try block does allow me to run the tests though:

from shutil import copyfile, SameFileError

for file in argv[3:]:
   try:
      copyfile(os.path.join(argv[1],file),file)
   except SameFileError:
      pass

Operating system Arch Linux, Python version 3.10.7

susilehtola commented 2 years ago

MOPAC is not designed to do in-source builds. Instead of cmake ., create an out-of-root build directory mkdir objdir; cd objdir; cmake .. and the build and tests will succeed.

ntBre commented 2 years ago

Ah that makes sense with all of the git changes I saw too. Thanks!