[test/subset] Remove tempdir

Was creating a tempdir in /tmp for every single test item,
and not removing it.  Create one per test file, and remove
if test successful.
This commit is contained in:
Behdad Esfahbod committed 2025-03-25 15:36:39 -06:00
1 parent bed29d1cd3
commit 4d2a362f84
2 files changed
+9 -4

No files matched your search

+5 -2
View File
@@ -51,7 +51,7 @@ def fail_test(test, cli_args, message):
def run_test(test, should_check_ots):
out_file = os.path.join(tempfile.mkdtemp(), test.font_name + "-subset.ttf")
out_file = os.path.join(out_dir, test.font_name + "-subset.ttf")
cli_args = [
"--font-file=" + test.font_path(),
"--output-file=" + out_file,
@@ -117,12 +117,15 @@ path = args[0]
if not path.endswith(".tests"):
sys.exit("Not a valid test case path.")
out_dir = tempfile.mkdtemp()
with open(path, mode="r", encoding="utf-8") as f:
# TODO(garretrieger): re-enable OTS checking.
fails += run_test(RepackTest(path, f.read()), False)
if fails != 0:
sys.exit("%d test(s) failed." % fails)
sys.exit("%d test(s) failed; output left in %s" % (fails, out_dir))
else:
print("All tests passed.")
shutil.rmtree(out_dir)
+4 -2
View File
@@ -59,7 +59,7 @@ def fail_test(test, cli_args, message):
def run_test(test, should_check_ots, preprocess):
out_file = os.path.join(
tempfile.mkdtemp(), test.get_font_name() + "-subset" + test.get_font_extension()
out_dir, test.get_font_name() + "-subset" + test.get_font_extension()
)
cli_args = [
"--font-file=" + test.font_path,
@@ -187,6 +187,7 @@ def open_subset_batch_process():
subset_process = open_subset_batch_process()
out_dir = tempfile.mkdtemp()
fails = 0
for path in args:
@@ -200,6 +201,7 @@ for path in args:
fails += run_test(test, has_ots, True)
if fails != 0:
sys.exit("%d test(s) failed." % fails)
sys.exit("%d test(s) failed; output left in %s" % (fails, out_dir))
else:
print("All tests passed.")
shutil.rmtree(out_dir)