numba icon indicating copy to clipboard operation
numba copied to clipboard

Can't execute python tests directly without using runtests.py

Open yashssh opened this issue 1 year ago • 2 comments

When I try invoking the test files directly like

python numba/tests/test_refop_pruning.py
python numba/tests/test_debuginfo.py

some of the tests fail with below error:

(llvmlite-3.10) yashwants@dev ~/work/numba (main) $ python numba/tests/test_debuginfo.py 
.....FF.........
======================================================================
FAIL: test_DILocation_decref (__main__.TestDebugInfoEmission)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/yashwants/venv/llvmlite-3.10/lib/python3.10/site-packages/numba-0.61.0.dev0+137.gfca98287a-py3.10-linux-aarch64.egg/numba/tests/support.py", line 643, in inner
    self.subprocess_test_runner(
  File "/home/yashwants/venv/llvmlite-3.10/lib/python3.10/site-packages/numba-0.61.0.dev0+137.gfca98287a-py3.10-linux-aarch64.egg/numba/tests/support.py", line 624, in subprocess_test_runner
    self.assertEqual(status.returncode, 0, streams)
AssertionError: 1 != 0 : 
captured stdout: 
captured stderr: E
======================================================================
ERROR: TestDebugInfoEmission (unittest.loader._FailedTest)
----------------------------------------------------------------------
AttributeError: module '__main__' has no attribute 'TestDebugInfoEmission'

----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (errors=1)


======================================================================
FAIL: test_DILocation_entry_blk (__main__.TestDebugInfoEmission)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/yashwants/venv/llvmlite-3.10/lib/python3.10/site-packages/numba-0.61.0.dev0+137.gfca98287a-py3.10-linux-aarch64.egg/numba/tests/support.py", line 643, in inner
    self.subprocess_test_runner(
  File "/home/yashwants/venv/llvmlite-3.10/lib/python3.10/site-packages/numba-0.61.0.dev0+137.gfca98287a-py3.10-linux-aarch64.egg/numba/tests/support.py", line 624, in subprocess_test_runner
    self.assertEqual(status.returncode, 0, streams)
AssertionError: 1 != 0 : 
captured stdout: 
captured stderr: E
======================================================================
ERROR: TestDebugInfoEmission (unittest.loader._FailedTest)
----------------------------------------------------------------------
AttributeError: module '__main__' has no attribute 'TestDebugInfoEmission'

----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (errors=1)


----------------------------------------------------------------------
Ran 16 tests in 3.446s

FAILED (failures=2)

Please note they work as expected if I make use of runtests.py for instance

python runtests.py numba/tests/test_debuginfo.py

python runtests.py numba.tests.test_debuginfo

work as expected.

yashssh avatar Jul 24 '24 10:07 yashssh

Thanks for reporting the issue @yashssh. It seems like the issue here is TestCase.run_test_in_subprocess protocol used in those specific tests isn't designed for running the files directly with the module being __main__. The subprocesses seem to be simply being invoked using the wrong module.

kc611 avatar Jul 30 '24 13:07 kc611

I am trying to fix the run_test_in_subprocess problem as part of #9460 in https://github.com/numba/numba/commit/c94cca32df90f796aca96c79309587113dbc03c6. By defining TestCase.run, I am able to make it work without the runtests script.

For now, there are other reason to use the runtests script or python -m numba.runtests, esp in multiprocessing mode. When running the full testsuite, a single process test run will use up too much memory and everything will slow down. The multiprocessing mode workaround it by using fresh processes every several hundred tests.

sklam avatar Jul 30 '24 14:07 sklam