diff options
-rw-r--r-- | SCons/Tool/ninja/__init__.py | 2 | ||||
-rw-r--r-- | test/ninja/force_scons_callback.py | 57 | ||||
-rw-r--r-- | test/ninja/ninja_test_sconscripts/sconstruct_force_scons_callback | 11 |
3 files changed, 38 insertions, 32 deletions
diff --git a/SCons/Tool/ninja/__init__.py b/SCons/Tool/ninja/__init__.py index 9fe9dd4..913738a 100644 --- a/SCons/Tool/ninja/__init__.py +++ b/SCons/Tool/ninja/__init__.py @@ -189,7 +189,7 @@ def generate(env): env["NINJA_ALIAS_NAME"] = env.get("NINJA_ALIAS_NAME", "generate-ninja") env['NINJA_DIR'] = env.Dir(env.get("NINJA_DIR", '#/.ninja')) env["NINJA_SCONS_DAEMON_KEEP_ALIVE"] = env.get("NINJA_SCONS_DAEMON_KEEP_ALIVE", 180000) - env["NINJA_SCONS_DAEMON_PORT"] = env.get('NINJA_SCONS_DAEMON_PORT', random.randint(10000,60000)) + env["NINJA_SCONS_DAEMON_PORT"] = env.get('NINJA_SCONS_DAEMON_PORT', random.randint(10000, 60000)) if GetOption("disable_ninja"): env.SConsignFile(os.path.join(str(env['NINJA_DIR']),'.ninja.sconsign')) diff --git a/test/ninja/force_scons_callback.py b/test/ninja/force_scons_callback.py index 59b54a0..c99ed58 100644 --- a/test/ninja/force_scons_callback.py +++ b/test/ninja/force_scons_callback.py @@ -37,47 +37,50 @@ except ImportError: _python_ = TestSCons._python_ _exe = TestSCons._exe -ninja_bin = os.path.abspath(os.path.join( - ninja.__file__, - os.pardir, - 'data', - 'bin', - 'ninja' + _exe)) +ninja_bin = os.path.abspath( + os.path.join(ninja.__file__, os.pardir, "data", "bin", "ninja" + _exe) +) -test.dir_fixture('ninja-fixture') +test.dir_fixture("ninja-fixture") -test.file_fixture('ninja_test_sconscripts/sconstruct_force_scons_callback', 'SConstruct') +test.file_fixture( + "ninja_test_sconscripts/sconstruct_force_scons_callback", "SConstruct" +) # generate simple build test.run(stdout=None) -test.must_contain_all_lines(test.stdout(), ['Generating: build.ninja']) -test.must_contain_all(test.stdout(), 'Executing:') -test.must_contain_all(test.stdout(), 'ninja%(_exe)s -f' % locals()) -if test.stdout().count('Defer to SCons to build') != 1: +test.must_contain_all_lines(test.stdout(), ["Generating: build.ninja"]) +test.must_contain_all(test.stdout(), "Executing:") +test.must_contain_all(test.stdout(), "ninja%(_exe)s -f" % locals()) +if test.stdout().count("Defer to SCons to build") != 1: test.fail_test() -test.must_match('out.txt', 'foo.c' + os.linesep) -test.must_match('out2.txt', "test2.cpp" + os.linesep) +test.must_match("out.txt", "foo.c" + os.linesep) +test.must_match("out2.txt", "test2.cpp" + os.linesep) # clean build and ninja files -test.run(arguments='-c', stdout=None) -test.must_contain_all_lines(test.stdout(), [ - 'Removed out.txt', - 'Removed out2.txt', - 'Removed build.ninja']) +test.run(arguments="-c", stdout=None) +test.must_contain_all_lines( + test.stdout(), ["Removed out.txt", "Removed out2.txt", "Removed build.ninja"] +) # only generate the ninja file -test.run(arguments='--disable-execute-ninja', stdout=None) -test.must_contain_all_lines(test.stdout(), ['Generating: build.ninja']) -test.must_not_exist(test.workpath('out.txt')) -test.must_not_exist(test.workpath('out2.txt')) +test.run(arguments="--disable-execute-ninja", stdout=None) +test.must_contain_all_lines(test.stdout(), ["Generating: build.ninja"]) +test.must_not_exist(test.workpath("out.txt")) +test.must_not_exist(test.workpath("out2.txt")) # run ninja independently -program = test.workpath('run_ninja_env.bat') if IS_WINDOWS else ninja_bin +program = test.workpath("run_ninja_env.bat") if IS_WINDOWS else ninja_bin test.run(program=program, stdout=None) -if test.stdout().count('Defer to SCons to build') != 1: +if test.stdout().count("Defer to SCons to build") != 1: test.fail_test() -test.must_match('out.txt', 'foo.c' + os.linesep) -test.must_match('out2.txt', "test2.cpp" + os.linesep) +test.must_match("out.txt", "foo.c" + os.linesep) +test.must_match("out2.txt", "test2.cpp" + os.linesep) + +# only generate the ninja file with specific NINJA_SCONS_DAEMON_PORT +test.run(arguments="PORT=9999 --disable-execute-ninja", stdout=None) +# Verify that port # propagates to call to ninja_run_daemon.py +test.must_contain(test.workpath("build.ninja"), "ninja_run_daemon.py 9999") test.pass_test() diff --git a/test/ninja/ninja_test_sconscripts/sconstruct_force_scons_callback b/test/ninja/ninja_test_sconscripts/sconstruct_force_scons_callback index 55729a6..ef3562b 100644 --- a/test/ninja/ninja_test_sconscripts/sconstruct_force_scons_callback +++ b/test/ninja/ninja_test_sconscripts/sconstruct_force_scons_callback @@ -1,8 +1,11 @@ -SetOption('experimental','ninja') +SetOption("experimental", "ninja") DefaultEnvironment(tools=[]) env = Environment(tools=[]) -env.Tool('ninja') +daemon_port = ARGUMENTS.get("PORT", False) +if daemon_port: + env["NINJA_SCONS_DAEMON_PORT"] = int(daemon_port) +env.Tool("ninja") -env.Command('out.txt', 'foo.c', 'echo $SOURCE> $TARGET', NINJA_FORCE_SCONS_BUILD=True) -env.Command('out2.txt', 'test2.cpp', 'echo $SOURCE> $TARGET')
\ No newline at end of file +env.Command("out.txt", "foo.c", "echo $SOURCE> $TARGET", NINJA_FORCE_SCONS_BUILD=True) +env.Command("out2.txt", "test2.cpp", "echo $SOURCE> $TARGET") |