Skip to content
Merged
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
9 changes: 8 additions & 1 deletion tests/test_feature_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ def run_scan(self, shaders, report, *, fail_writes=False):
preexec_fn=self.fail_file_writes if fail_writes else None,
)

@unittest.skipIf(os.name == "nt", "preexec_fn, which these two cases need, is POSIX-only")
def test_failed_write_keeps_existing_report(self):
with tempfile.TemporaryDirectory() as root:
shaders = self.make_shaders(root)
Expand All @@ -604,6 +605,7 @@ def test_failed_write_keeps_existing_report(self):
with open(report, "rb") as stream:
self.assertEqual(stream.read(), original)

@unittest.skipIf(os.name == "nt", "preexec_fn, which these two cases need, is POSIX-only")
def test_failed_write_leaves_no_temporary_file(self):
with tempfile.TemporaryDirectory() as root:
shaders = self.make_shaders(root)
Expand Down Expand Up @@ -633,7 +635,12 @@ def test_success_writes_valid_json(self):
if __name__ == "__main__":
# Every test_* function in the file, in file order, so a new test can't be left out of the script run.
raised = run_tests([fn for name, fn in list(globals().items()) if name.startswith("test_") and callable(fn)])
ok = not failures and not raised
# The class's cases are unittest methods, so the `test_*` scan above cannot see them: without this the script run
# (CI's standard-library job) skips them silently.
class_result = unittest.TextTestRunner(verbosity=0).run(
unittest.defaultTestLoader.loadTestsFromTestCase(FeatureScanAtomicOutputTests))
class_failed = len(class_result.failures) + len(class_result.errors)
ok = not failures and not raised and not class_failed
print(f"test_feature_scan: {'OK' if ok else 'FAILED'} ({failures} failed check{'s' if failures != 1 else ''}, "
f"{len(raised)} failed test{'s' if len(raised) != 1 else ''})")
sys.exit(0 if ok else 1)