diff --git a/test/ninja/build_libraries.py b/test/ninja/build_libraries.py index 0561f6f54..9436053c7 100644 --- a/test/ninja/build_libraries.py +++ b/test/ninja/build_libraries.py @@ -34,7 +34,7 @@ except ImportError: test.skip_test("Could not find ninja module. Skipping test.\n") -ninja_bin = test.ninja_binary() +ninja_bin = TestSCons.NINJA_BINARY test.dir_fixture('ninja-fixture') diff --git a/test/ninja/command_line_targets.py b/test/ninja/command_line_targets.py index b043f62bc..1a6033b9e 100644 --- a/test/ninja/command_line_targets.py +++ b/test/ninja/command_line_targets.py @@ -36,7 +36,7 @@ _python_ = TestSCons._python_ _exe = TestSCons._exe -ninja_bin = test.ninja_binary() +ninja_bin = TestSCons.NINJA_BINARY test.dir_fixture('ninja-fixture') diff --git a/test/ninja/copy_function_command.py b/test/ninja/copy_function_command.py index 13036ee3a..e8721a19d 100644 --- a/test/ninja/copy_function_command.py +++ b/test/ninja/copy_function_command.py @@ -37,7 +37,7 @@ _python_ = TestSCons._python_ _exe = TestSCons._exe -ninja_bin = test.ninja_binary() +ninja_bin = TestSCons.NINJA_BINARY test.dir_fixture('ninja-fixture') diff --git a/test/ninja/default_targets.py b/test/ninja/default_targets.py index 7752d5ab7..e809d7537 100644 --- a/test/ninja/default_targets.py +++ b/test/ninja/default_targets.py @@ -36,7 +36,7 @@ _python_ = TestSCons._python_ _exe = TestSCons._exe -ninja_bin = test.ninja_binary() +ninja_bin = TestSCons.NINJA_BINARY test.dir_fixture('ninja-fixture') diff --git a/test/ninja/force_scons_callback.py b/test/ninja/force_scons_callback.py index b668f92c9..3ae5a5a61 100644 --- a/test/ninja/force_scons_callback.py +++ b/test/ninja/force_scons_callback.py @@ -37,8 +37,7 @@ _python_ = TestSCons._python_ _exe = TestSCons._exe -ninja_bin = test.ninja_binary() - +ninja_bin = TestSCons.NINJA_BINARY test.dir_fixture("ninja-fixture") diff --git a/test/ninja/generate_and_build.py b/test/ninja/generate_and_build.py index c14af7045..9d056836f 100644 --- a/test/ninja/generate_and_build.py +++ b/test/ninja/generate_and_build.py @@ -37,7 +37,7 @@ _python_ = TestSCons._python_ _exe = TestSCons._exe -ninja_bin = test.ninja_binary() +ninja_bin = TestSCons.NINJA_BINARY test.dir_fixture('ninja-fixture') diff --git a/test/ninja/generate_and_build_cxx.py b/test/ninja/generate_and_build_cxx.py index 51f68dca0..80faa4bbe 100644 --- a/test/ninja/generate_and_build_cxx.py +++ b/test/ninja/generate_and_build_cxx.py @@ -37,7 +37,7 @@ _python_ = TestSCons._python_ _exe = TestSCons._exe -ninja_bin = test.ninja_binary() +ninja_bin = TestSCons.NINJA_BINARY test.dir_fixture('ninja-fixture') diff --git a/test/ninja/generate_source.py b/test/ninja/generate_source.py index f4bd0c0ae..b848b17c1 100644 --- a/test/ninja/generate_source.py +++ b/test/ninja/generate_source.py @@ -37,7 +37,7 @@ _python_ = TestSCons._python_ _exe = TestSCons._exe -ninja_bin = test.ninja_binary() +ninja_bin = TestSCons.NINJA_BINARY test.dir_fixture('ninja-fixture') diff --git a/test/ninja/generated_sources_alias.py b/test/ninja/generated_sources_alias.py index 3e7f9d16b..22ca734b3 100644 --- a/test/ninja/generated_sources_alias.py +++ b/test/ninja/generated_sources_alias.py @@ -37,8 +37,7 @@ _python_ = TestSCons._python_ _exe = TestSCons._exe -ninja_bin = test.ninja_binary() - +ninja_bin = TestSCons.NINJA_BINARY test.dir_fixture('ninja-fixture') diff --git a/test/ninja/iterative_speedup.py b/test/ninja/iterative_speedup.py index 819017532..cbd4b6ac9 100644 --- a/test/ninja/iterative_speedup.py +++ b/test/ninja/iterative_speedup.py @@ -39,7 +39,7 @@ _python_ = TestSCons._python_ _exe = TestSCons._exe -ninja_bin = test.ninja_binary() +ninja_bin = TestSCons.NINJA_BINARY test.dir_fixture('ninja-fixture') diff --git a/test/ninja/mingw_command_generator_action.py b/test/ninja/mingw_command_generator_action.py index 8fc08a816..ad7878469 100644 --- a/test/ninja/mingw_command_generator_action.py +++ b/test/ninja/mingw_command_generator_action.py @@ -52,7 +52,7 @@ _python_ = TestSCons._python_ _exe = TestSCons._exe -ninja_bin = test.ninja_binary() +ninja_bin = TestSCons.NINJA_BINARY test.dir_fixture('ninja-fixture') diff --git a/test/ninja/mingw_depfile_format.py b/test/ninja/mingw_depfile_format.py index e9c89a0f6..7792440d0 100644 --- a/test/ninja/mingw_depfile_format.py +++ b/test/ninja/mingw_depfile_format.py @@ -36,7 +36,7 @@ _python_ = TestSCons._python_ _exe = TestSCons._exe -ninja_bin = test.ninja_binary() +ninja_bin = TestSCons.NINJA_BINARY test.dir_fixture('ninja-fixture') diff --git a/test/ninja/mkdir_function_command.py b/test/ninja/mkdir_function_command.py index c01cb982f..3fd678a3f 100644 --- a/test/ninja/mkdir_function_command.py +++ b/test/ninja/mkdir_function_command.py @@ -37,7 +37,7 @@ _python_ = TestSCons._python_ _exe = TestSCons._exe -ninja_bin = test.ninja_binary() +ninja_bin = TestSCons.NINJA_BINARY test.write('SConstruct', """ SetOption('experimental','ninja') diff --git a/test/ninja/multi_env.py b/test/ninja/multi_env.py index 6aaeccd58..7b113ed22 100644 --- a/test/ninja/multi_env.py +++ b/test/ninja/multi_env.py @@ -37,7 +37,7 @@ _python_ = TestSCons._python_ _exe = TestSCons._exe -ninja_bin = test.ninja_binary() +ninja_bin = TestSCons.NINJA_BINARY test = TestSCons.TestSCons() diff --git a/test/ninja/ninja_command_line.py b/test/ninja/ninja_command_line.py index d6744aa71..8fc232e42 100644 --- a/test/ninja/ninja_command_line.py +++ b/test/ninja/ninja_command_line.py @@ -37,7 +37,7 @@ _python_ = TestSCons._python_ _exe = TestSCons._exe -ninja_bin = test.ninja_binary() +ninja_bin = TestSCons.NINJA_BINARY test.dir_fixture('ninja-fixture', 'src') diff --git a/test/ninja/ninja_conftest.py b/test/ninja/ninja_conftest.py index a92ecd993..60c4b033e 100644 --- a/test/ninja/ninja_conftest.py +++ b/test/ninja/ninja_conftest.py @@ -37,7 +37,7 @@ _python_ = TestSCons._python_ _exe = TestSCons._exe -ninja_bin = test.ninja_binary() +ninja_bin = TestSCons.NINJA_BINARY test.dir_fixture('ninja-fixture') diff --git a/test/ninja/ninja_file_deterministic.py b/test/ninja/ninja_file_deterministic.py index 232e7abba..3d226ca4e 100644 --- a/test/ninja/ninja_file_deterministic.py +++ b/test/ninja/ninja_file_deterministic.py @@ -39,7 +39,7 @@ _python_ = TestSCons._python_ _exe = TestSCons._exe -ninja_bin = test.ninja_binary() +ninja_bin = TestSCons.NINJA_BINARY test.dir_fixture('ninja-fixture') diff --git a/test/ninja/ninja_handle_control_c_rebuild.py b/test/ninja/ninja_handle_control_c_rebuild.py index 563536739..d187c5f43 100644 --- a/test/ninja/ninja_handle_control_c_rebuild.py +++ b/test/ninja/ninja_handle_control_c_rebuild.py @@ -40,8 +40,7 @@ _python_ = TestSCons._python_ _exe = TestSCons._exe - -ninja_bin = test.ninja_binary() +ninja_bin = TestSCons.NINJA_BINARY test.dir_fixture("ninja-fixture") diff --git a/test/ninja/no_for_sig_subst.py b/test/ninja/no_for_sig_subst.py index da33f8d1c..ef2c79599 100644 --- a/test/ninja/no_for_sig_subst.py +++ b/test/ninja/no_for_sig_subst.py @@ -37,7 +37,7 @@ _python_ = TestSCons._python_ _exe = TestSCons._exe -ninja_bin = test.ninja_binary() +ninja_bin = TestSCons.NINJA_BINARY test.dir_fixture('ninja-fixture') diff --git a/test/ninja/response_file.py b/test/ninja/response_file.py index e9f778ae8..f2561bbfa 100644 --- a/test/ninja/response_file.py +++ b/test/ninja/response_file.py @@ -42,7 +42,7 @@ _exe = TestSCons._exe _obj = TestSCons._obj -ninja_bin = test.ninja_binary() +ninja_bin = TestSCons.NINJA_BINARY test.dir_fixture('ninja-fixture') diff --git a/test/ninja/shell_command.py b/test/ninja/shell_command.py index 0ed8f2a0d..8b3d13429 100644 --- a/test/ninja/shell_command.py +++ b/test/ninja/shell_command.py @@ -37,7 +37,7 @@ _python_ = TestSCons._python_ _exe = TestSCons._exe -ninja_bin = test.ninja_binary() +ninja_bin = TestSCons.NINJA_BINARY test.dir_fixture('ninja-fixture') diff --git a/test/ninja/shutdown_scons_daemon.py b/test/ninja/shutdown_scons_daemon.py index 25823d742..c646f970f 100644 --- a/test/ninja/shutdown_scons_daemon.py +++ b/test/ninja/shutdown_scons_daemon.py @@ -44,7 +44,7 @@ _python_ = TestSCons._python_ _exe = TestSCons._exe -ninja_bin = test.ninja_binary() +ninja_bin = TestSCons.NINJA_BINARY test.dir_fixture("ninja-fixture") diff --git a/testing/framework/TestCmd.py b/testing/framework/TestCmd.py index 7307078c5..56c282c99 100644 --- a/testing/framework/TestCmd.py +++ b/testing/framework/TestCmd.py @@ -337,6 +337,9 @@ IS_ROOT = False NEED_HELPER = os.environ.get('SCONS_NO_DIRECT_SCRIPT') + + + # sentinel for cases where None won't do _Null = object() diff --git a/testing/framework/TestSCons.py b/testing/framework/TestSCons.py index d6c51251e..5c95c2423 100644 --- a/testing/framework/TestSCons.py +++ b/testing/framework/TestSCons.py @@ -74,7 +74,8 @@ 'lib_', '_lib', 'dll_', - '_dll' + '_dll', + 'NINJA_BINARY' ]) machine_map = { @@ -103,6 +104,12 @@ _dll = dll_suffix dll_ = dll_prefix +try: + import ninja + NINJA_BINARY = os.path.abspath(os.path.join(ninja.BIN_DIR, 'ninja' + _exe)) +except ImportError: + NINJA_BINARY = None + if sys.platform == 'cygwin': # On Cygwin, os.path.normcase() lies, so just report back the # fact that the underlying Win32 OS is case-insensitive. @@ -1087,15 +1094,6 @@ def java_get_class_files(self, dir): result.append(os.path.join(dirpath, fname)) return sorted(result) - def ninja_binary(self): - try: - import ninja - except ImportError: - return False - - return os.path.abspath(os.path.join(ninja.BIN_DIR, 'ninja' + _exe)) - - def Qt_dummy_installation(self, dir: str = 'qt') -> None: # create a dummy qt installation