Run C unit tests in a subprocess.
(self)
| 68 | # (Or don't. It is probably not a good use of time.) |
| 69 | @unittest.skipIf(sys.platform.startswith("win"), "rt tests don't work on windows") |
| 70 | def test_c_unit_test(self) -> None: |
| 71 | """Run C unit tests in a subprocess.""" |
| 72 | cppflags: list[str] = [] |
| 73 | env = os.environ.copy() |
| 74 | if sys.platform == "darwin": |
| 75 | cppflags += ["-O0", "-mmacosx-version-min=10.10", "-stdlib=libc++"] |
| 76 | elif sys.platform == "linux": |
| 77 | cppflags += ["-O0"] |
| 78 | env["CPPFLAGS"] = " ".join(cppflags) |
| 79 | # Build Python wrapper for C unit tests. |
| 80 | |
| 81 | with tempfile.TemporaryDirectory() as tmpdir: |
| 82 | status = subprocess.check_call( |
| 83 | [ |
| 84 | sys.executable, |
| 85 | "setup.py", |
| 86 | "build_ext", |
| 87 | f"--build-lib={tmpdir}", |
| 88 | f"--build-temp={tmpdir}", |
| 89 | "--run-capi-tests", |
| 90 | ], |
| 91 | env=env, |
| 92 | cwd=os.path.join(PREFIX, "mypyc", "lib-rt"), |
| 93 | ) |
| 94 | # Run C unit tests. |
| 95 | env = os.environ.copy() |
| 96 | if "GTEST_COLOR" not in os.environ: |
| 97 | env["GTEST_COLOR"] = "yes" # Use fancy colors |
| 98 | status = subprocess.call( |
| 99 | [sys.executable, "-c", "import sys, test_capi; sys.exit(test_capi.run_tests())"], |
| 100 | env=env, |
| 101 | cwd=tmpdir, |
| 102 | ) |
| 103 | if status != 0: |
| 104 | raise AssertionError("make test: C unit test failure") |
nothing calls this directly
no test coverage detected