Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,22 @@ jobs:
run: |
python -m unittest discover -s tests/semantic > "$RUNNER_TEMP/semantic.log" 2>&1 &
semantic=$!
failed=()
while IFS= read -r t; do
if grep -Eq "$PYTEST_FILE_MARKERS" "$t" || ! grep -q '__main__' "$t"; then
continue
fi
echo "== $t"
python -I "$t" || exit 1
python -I "$t" || failed+=("$t")
done < <(find tests -path 'tests/semantic' -prune -o -type f -name 'test_*.py' -print | LC_ALL=C sort)
status=0
wait "$semantic" || status=$?
echo "== tests/semantic"
cat "$RUNNER_TEMP/semantic.log"
if (( ${#failed[@]} )); then
for t in "${failed[@]}"; do echo "::error file=$t::$t failed"; done
status=1
fi
exit "$status"
- name: Install llvm-mc and SPIRV-Tools
run: |
Expand Down Expand Up @@ -306,10 +311,15 @@ jobs:
- name: Tests (standard library only, Linux)
shell: bash
run: |
failed=()
while IFS= read -r t; do
if grep -Eq "$PYTEST_FILE_MARKERS" "$t" || ! grep -q '__main__' "$t"; then
continue
fi
echo "== $t"
python -I "$t" || exit 1
python -I "$t" || failed+=("$t")
done < <(find tests -path 'tests/semantic' -prune -o -type f -name 'test_*.py' -print | LC_ALL=C sort)
if (( ${#failed[@]} )); then
for t in "${failed[@]}"; do echo "::error file=$t::$t failed"; done
exit 1
fi
3 changes: 2 additions & 1 deletion scripts/run_semantic_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,9 @@ def main(argv=None):


if __name__ == "__main__":
try: # a redirected stdout is strict ANSI code page under -I; write '?' for what it cannot encode
try: # a redirected stdout/stderr is strict ANSI code page under -I; write '?' for what it cannot encode
sys.stdout.reconfigure(errors="replace")
sys.stderr.reconfigure(errors="replace")
except (AttributeError, ValueError, OSError):
pass
try:
Expand Down
5 changes: 5 additions & 0 deletions scripts/run_wine_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,4 +604,9 @@ def report(index: int) -> None:


if __name__ == "__main__":
try: # a redirected stdout/stderr is strict ANSI code page under -I; write '?' for what it cannot encode
sys.stdout.reconfigure(errors="replace")
sys.stderr.reconfigure(errors="replace")
except (AttributeError, ValueError, OSError):
pass
sys.exit(main())
12 changes: 12 additions & 0 deletions tests/test_ci_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,18 @@ def test_step_script_reads_the_check_loop(self):
self.assertIn('python -I "$t"', script)
self.assertIn("-name 'test_*.py'", script)

def test_linux_stdlib_step_collects_all_failures(self):
script = step_script(ROOT, "Tests (standard library only, Linux)")
self.assertIn('failed=()', script)
self.assertIn('python -I "$t" || failed+=("$t")', script)
self.assertIn('::error file=$t::$t failed', script)

def test_macos_stdlib_step_collects_all_failures(self):
script = step_script(ROOT, "Translator semantic tests and tests (standard library only, no game data)")
self.assertIn('failed=()', script)
self.assertIn('python -I "$t" || failed+=("$t")', script)
self.assertIn('::error file=$t::$t failed', script)


if __name__ == "__main__":
unittest.main()
5 changes: 5 additions & 0 deletions tests/test_run_semantic_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@ def test_posix_sigint_cancels_queued_modules_and_stops_runner(self):
self.assertNotIn("5 files,", stdout)
self.assertEqual(len(os.listdir(marker_dir)), 2)

def test_cli_reconfigures_streams_cleanly(self):
result = cli("unused-suite", "-h")
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
self.assertIn("Run the translator regression suite", result.stdout)


if __name__ == "__main__":
unittest.main()
6 changes: 6 additions & 0 deletions tests/test_run_wine_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,12 @@ def test_wine_quoting_is_still_split(self):
with self.assertRaises(argparse.ArgumentTypeError):
rwt.wine_command(" ")

def test_cli_help_under_python_isolated(self):
result = subprocess.run([sys.executable, "-I", str(Path(rwt.__file__).resolve()), "--help"],
capture_output=True, text=True, timeout=15)
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
self.assertIn("Run the Windows build's CTest tests under Wine", result.stdout)


if __name__ == "__main__":
unittest.main()
Loading