NCAR / ccpp-framework

Common Community Physics Package (CCPP)
http://www.dtcenter.org/community-code/common-community-physics-package-ccpp/
Other
26 stars 63 forks source link

capgen unit tests broken in main branch #497

Closed climbfuji closed 11 months ago

climbfuji commented 11 months ago

Description

The capgen unit tests are broken in the main branch:

Everything ok up to unit testing common.py:

..E..
======================================================================
ERROR: test_execute (__main__.CommonTestCase)
Test execute() function
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/heinzell/work/ccpp-framework/ccpp-framework/test/unit_tests/test_common.py", line 41, in test_execute
    self.assertEqual(common.execute(f"ls {TEST_FILE}"),(0,f"{TEST_FILE}",""))
  File "/Users/heinzell/work/ccpp-framework/ccpp-framework/scripts/common.py", line 98, in execute
    raise Exception(message)
Exception: Execution of command ls test_common.py failed, exit code 1
    stdout: ""
    stderr: "ls: test_common.py: No such file or directory"

----------------------------------------------------------------------
Ran 5 tests in 0.032s

FAILED (errors=1)

Solution

Clearly a bug, because the test assumes that the file is in the local directory where the tests are executed, which is not the case if you run run_tests.sh in directory ./test. Simple fix is to use os.path.abspath.

Alternatives (optional)

n/a

Related to (optional)

n/a