test: replace pass_* functions with a test.json entry

pull/6666/head
Daniel Mensinger 5 years ago
parent 8e60b8c146
commit 12930051ae
No known key found for this signature in database
GPG Key ID: 54DD94C131E277D4
  1. 29
      run_project_tests.py
  2. 3
      test cases/common/195 install_mode/test.json
  3. 3
      test cases/common/8 install/test.json
  4. 3
      test cases/failing/38 libdir must be inside prefix/test.json
  5. 3
      test cases/failing/39 prefix absolute/test.json

@ -145,6 +145,7 @@ class TestDef:
self.skip = skip self.skip = skip
self.env = os.environ.copy() self.env = os.environ.copy()
self.installed_files = [] # type: T.List[InstalledFile] self.installed_files = [] # type: T.List[InstalledFile]
self.do_not_set_opts = [] # type: T.List[str]
def __repr__(self) -> str: def __repr__(self) -> str:
return '<{}: {:<48} [{}: {}] -- {}>'.format(type(self).__name__, str(self.path), self.name, self.args, self.skip) return '<{}: {:<48} [{}: {}] -- {}>'.format(type(self).__name__, str(self.path), self.name, self.args, self.skip)
@ -378,29 +379,14 @@ def run_test(test: TestDef, extra_args, compiler, backend, flags, commands, shou
finally: finally:
mlog.shutdown() # Close the log file because otherwise Windows wets itself. mlog.shutdown() # Close the log file because otherwise Windows wets itself.
def pass_prefix_to_test(dirname: Path):
if '39 prefix absolute' in dirname.name:
return False
return True
def pass_libdir_to_test(dirname: Path):
if '8 install' in dirname.name:
return False
if '38 libdir must be inside prefix' in dirname.name:
return False
if '195 install_mode' in dirname.name:
return False
return True
def _run_test(test: TestDef, test_build_dir: str, install_dir: str, extra_args, compiler, backend, flags, commands, should_fail): def _run_test(test: TestDef, test_build_dir: str, install_dir: str, extra_args, compiler, backend, flags, commands, should_fail):
compile_commands, clean_commands, install_commands, uninstall_commands = commands compile_commands, clean_commands, install_commands, uninstall_commands = commands
gen_start = time.time() gen_start = time.time()
# Configure in-process # Configure in-process
if pass_prefix_to_test(test.path): gen_args = [] # type: T.List[str]
gen_args = ['--prefix', 'x:/usr'] if mesonlib.is_windows() else ['--prefix', '/usr'] if 'prefix' not in test.do_not_set_opts:
else: gen_args += ['--prefix', 'x:/usr'] if mesonlib.is_windows() else ['--prefix', '/usr']
gen_args = [] if 'libdir' not in test.do_not_set_opts:
if pass_libdir_to_test(test.path):
gen_args += ['--libdir', 'lib'] gen_args += ['--libdir', 'lib']
gen_args += [test.path.as_posix(), test_build_dir] + flags + extra_args gen_args += [test.path.as_posix(), test_build_dir] + flags + extra_args
nativefile = test.path / 'nativefile.ini' nativefile = test.path / 'nativefile.ini'
@ -521,10 +507,14 @@ def gather_tests(testdir: Path) -> T.List[TestDef]:
if 'installed' in test_def: if 'installed' in test_def:
installed = [InstalledFile(x) for x in test_def['installed']] installed = [InstalledFile(x) for x in test_def['installed']]
# Handle the do_not_set_opts list
do_not_set_opts = test_def.get('do_not_set_opts', []) # type: T.List[str]
# Skip the matrix code and just update the existing test # Skip the matrix code and just update the existing test
if 'matrix' not in test_def: if 'matrix' not in test_def:
t.env.update(env) t.env.update(env)
t.installed_files = installed t.installed_files = installed
t.do_not_set_opts = do_not_set_opts
all_tests += [t] all_tests += [t]
continue continue
@ -594,6 +584,7 @@ def gather_tests(testdir: Path) -> T.List[TestDef]:
test = TestDef(t.path, name, opts, skip) test = TestDef(t.path, name, opts, skip)
test.env.update(env) test.env.update(env)
test.installed_files = installed test.installed_files = installed
test.do_not_set_opts = do_not_set_opts
all_tests += [test] all_tests += [test]
return sorted(all_tests) return sorted(all_tests)

@ -10,5 +10,6 @@
{"type": "file", "file": "usr/share/sub1/second.dat"}, {"type": "file", "file": "usr/share/sub1/second.dat"},
{"type": "file", "file": "usr/share/sub2/stub"}, {"type": "file", "file": "usr/share/sub2/stub"},
{"type": "file", "file": "usr/subdir/data.dat"} {"type": "file", "file": "usr/subdir/data.dat"}
] ],
"do_not_set_opts": ["libdir"]
} }

@ -3,5 +3,6 @@
{ "type": "exe", "file": "usr/bin/prog" }, { "type": "exe", "file": "usr/bin/prog" },
{ "type": "pdb", "file": "usr/bin/prog" }, { "type": "pdb", "file": "usr/bin/prog" },
{ "type": "file", "file": "usr/libtest/libstat.a" } { "type": "file", "file": "usr/libtest/libstat.a" }
] ],
"do_not_set_opts": ["libdir"]
} }

@ -0,0 +1,3 @@
{
"do_not_set_opts": ["prefix"]
}
Loading…
Cancel
Save