tests: Clean up leftover files from source dirs.

pull/13086/merge
Jussi Pakkanen 5 months ago committed by GitHub
parent 9a60deff0a
commit 47fd13aefc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      data/test.schema.json
  2. 6
      mesonbuild/utils/universal.py
  3. 15
      run_project_tests.py
  4. 3
      test cases/common/153 wrap file should not failed/test.json
  5. 3
      test cases/common/258 subsubproject inplace/test.json
  6. 3
      test cases/rust/25 cargo lock/test.json

@ -178,6 +178,12 @@
"items": {
"type": "string"
}
},
"cleanup": {
"type": "array",
"items": {
"type": "string"
}
}
}
}

@ -1788,7 +1788,7 @@ def get_filenames_templates_dict(inputs: T.List[str], outputs: T.List[str]) -> T
return values
def _make_tree_writable(topdir: str) -> None:
def _make_tree_writable(topdir: T.Union[str, Path]) -> None:
# Ensure all files and directories under topdir are writable
# (and readable) by owner.
for d, _, files in os.walk(topdir):
@ -1799,7 +1799,7 @@ def _make_tree_writable(topdir: str) -> None:
os.chmod(fpath, os.stat(fpath).st_mode | stat.S_IWRITE | stat.S_IREAD)
def windows_proof_rmtree(f: str) -> None:
def windows_proof_rmtree(f: T.Union[str, Path]) -> None:
# On Windows if anyone is holding a file open you can't
# delete it. As an example an anti virus scanner might
# be scanning files you are trying to delete. The only
@ -1826,7 +1826,7 @@ def windows_proof_rmtree(f: str) -> None:
shutil.rmtree(f)
def windows_proof_rm(fpath: str) -> None:
def windows_proof_rm(fpath: T.Union[str, Path]) -> None:
"""Like windows_proof_rmtree, but for a single file."""
if os.path.isfile(fpath):
os.chmod(fpath, os.stat(fpath).st_mode | stat.S_IWRITE | stat.S_IREAD)

@ -278,6 +278,7 @@ class TestDef:
self.stdout: T.List[T.Dict[str, str]] = []
self.skip_category = skip_category
self.skip_expected = False
self.cleanup: T.List[str] = []
# Always print a stack trace for Meson exceptions
self.env['MESON_FORCE_BACKTRACE'] = '1'
@ -844,6 +845,8 @@ def load_test_json(t: TestDef, stdout_mandatory: bool, skip_category: bool = Fal
(t.skip, t.skip_expected) = _skip_keys(test_def)
cleanup = test_def.get('cleanup', [])
# Skip tests if the tool requirements are not met
if 'tools' in test_def:
assert isinstance(test_def['tools'], dict)
@ -859,6 +862,7 @@ def load_test_json(t: TestDef, stdout_mandatory: bool, skip_category: bool = Fal
t.installed_files = installed
t.do_not_set_opts = do_not_set_opts
t.stdout = stdout
t.cleanup = cleanup
return [t]
new_opt_list: T.List[T.List[T.Tuple[str, str, bool, bool]]]
@ -928,6 +932,8 @@ def load_test_json(t: TestDef, stdout_mandatory: bool, skip_category: bool = Fal
test.do_not_set_opts = do_not_set_opts
test.stdout = stdout
test.skip_expected = skip_expected or t.skip_expected
test.cleanup = cleanup
all_tests.append(test)
return all_tests
@ -1393,6 +1399,13 @@ def _run_tests(all_tests: T.List[T.Tuple[str, T.List[TestDef], bool]],
else:
f.update_log(TestStatus.OK)
passing_tests += 1
for cleanup_path in t.cleanup:
assert not os.path.isabs(cleanup_path)
abspath = t.path / cleanup_path
if abspath.is_file():
mesonlib.windows_proof_rm(abspath)
else:
mesonlib.windows_proof_rmtree(abspath)
conf_time += result.conftime
build_time += result.buildtime
test_time += result.testtime
@ -1550,7 +1563,7 @@ def print_tool_versions() -> None:
print()
tmpdir = list(Path('.').glob('test cases/**/*install functions and follow symlinks'))
assert(len(tmpdir) == 1)
assert len(tmpdir) == 1
symlink_test_dir = tmpdir[0]
symlink_file1 = symlink_test_dir / 'foo/link1'
symlink_file2 = symlink_test_dir / 'foo/link2.h'

@ -0,0 +1,3 @@
{
"cleanup": ["subprojects/foo-1.0-patchfile"]
}

@ -0,0 +1,3 @@
{
"cleanup": ["subprojects/subsub.wrap"]
}

@ -0,0 +1,3 @@
{
"cleanup": ["subprojects/bar-0.1"]
}
Loading…
Cancel
Save