diff options
53 files changed, 153 insertions, 227 deletions
diff --git a/test/actions-bare/gyptest-bare.py b/test/actions-bare/gyptest-bare.py index 2ad506de..eab6d2a1 100644 --- a/test/actions-bare/gyptest-bare.py +++ b/test/actions-bare/gyptest-bare.py @@ -10,7 +10,7 @@ test = TestGyp.TestGyp() test.run_gyp('bare.gyp', chdir='src') test.relocate('src', 'relocate/src') -test.build_default('bare.gyp', chdir='relocate/src') +test.build('bare.gyp', chdir='relocate/src') file_content = 'Hello from bare.py\n' diff --git a/test/actions-subdir/gyptest-action.py b/test/actions-subdir/gyptest-action.py index c48a7432..92f86775 100644 --- a/test/actions-subdir/gyptest-action.py +++ b/test/actions-subdir/gyptest-action.py @@ -11,7 +11,7 @@ test = TestGyp.TestGyp(formats=['!xcode']) test.run_gyp('none.gyp', chdir='src') -test.build_all('none.gyp', chdir='src') +test.build('none.gyp', test.ALL, chdir='src') file_content = 'Hello from make-file.py\n' subdir_file_content = 'Hello from make-subdir-file.py\n' diff --git a/test/actions/gyptest-all.py b/test/actions/gyptest-all.py index 0eb65a2d..6452e026 100644 --- a/test/actions/gyptest-all.py +++ b/test/actions/gyptest-all.py @@ -12,7 +12,7 @@ test.run_gyp('actions.gyp', chdir='src') test.relocate('src', 'relocate/src') -test.build_all('actions.gyp', chdir='relocate/src') +test.build('actions.gyp', test.ALL, chdir='relocate/src') expect = """\ diff --git a/test/actions/gyptest-default.py b/test/actions/gyptest-default.py index 4f1d2aba..5ef8ec52 100644 --- a/test/actions/gyptest-default.py +++ b/test/actions/gyptest-default.py @@ -12,7 +12,7 @@ test.run_gyp('actions.gyp', chdir='src') test.relocate('src', 'relocate/src') -test.build_default('actions.gyp', chdir='relocate/src') +test.build('actions.gyp', chdir='relocate/src') expect = """\ diff --git a/test/assembly/gyptest-assembly.py b/test/assembly/gyptest-assembly.py index f117482c..4ab518c7 100644 --- a/test/assembly/gyptest-assembly.py +++ b/test/assembly/gyptest-assembly.py @@ -15,7 +15,7 @@ test.run_gyp('assembly.gyp', chdir='src') test.relocate('src', 'relocate/src') -test.build_all('assembly.gyp', chdir='relocate/src') +test.build('assembly.gyp', test.ALL, chdir='relocate/src') expect = """\ Hello from program.c diff --git a/test/builddir/gyptest-all.py b/test/builddir/gyptest-all.py index 8a24aa4f..f6b4d69b 100644 --- a/test/builddir/gyptest-all.py +++ b/test/builddir/gyptest-all.py @@ -33,7 +33,7 @@ test.writable('relocate', False) test.writable('relocate/builddir', True) # Suppress the test infrastructure's setting SYMROOT on the command line. -test.build_all('prog1.gyp', SYMROOT=None, chdir='relocate/src') +test.build('prog1.gyp', test.ALL, SYMROOT=None, chdir='relocate/src') expect1 = """\ Hello from prog1.c diff --git a/test/builddir/gyptest-default.py b/test/builddir/gyptest-default.py index adfc2233..3c8b730f 100644 --- a/test/builddir/gyptest-default.py +++ b/test/builddir/gyptest-default.py @@ -33,7 +33,7 @@ test.writable('relocate', False) test.writable('relocate/builddir', True) # Suppress the test infrastructure's setting SYMROOT on the command line. -test.build_default('prog1.gyp', SYMROOT=None, chdir='relocate/src') +test.build('prog1.gyp', SYMROOT=None, chdir='relocate/src') expect1 = """\ Hello from prog1.c diff --git a/test/compilable/gyptest-headers.py b/test/compilable/gyptest-headers.py index 0dd0a798..5d494507 100644 --- a/test/compilable/gyptest-headers.py +++ b/test/compilable/gyptest-headers.py @@ -13,7 +13,7 @@ test.run_gyp('headers.gyp', chdir='src') test.relocate('src', 'relocate/src') -test.build_all('headers.gyp', chdir='relocate/src') +test.build('headers.gyp', test.ALL, chdir='relocate/src') expect = """\ Hello from program.c diff --git a/test/configurations/gyptest-configurations.py b/test/configurations/gyptest-configurations.py index 1e022b5f..68532c4e 100644 --- a/test/configurations/gyptest-configurations.py +++ b/test/configurations/gyptest-configurations.py @@ -11,15 +11,15 @@ test = TestGyp.TestGyp() test.run_gyp('configurations.gyp') test.set_configuration('Release') -test.run_build('configurations.gyp') +test.build('configurations.gyp') test.run_built_executable('configurations', stdout="Release configuration\n") test.set_configuration('Debug') -test.run_build('configurations.gyp') +test.build('configurations.gyp') test.run_built_executable('configurations', stdout="Debug configuration\n") test.set_configuration('Foo') -test.run_build('configurations.gyp') +test.build('configurations.gyp') test.run_built_executable('configurations', stdout="Foo configuration\n") test.pass_test() diff --git a/test/copies-link/gyptest-copies-link.py b/test/copies-link/gyptest-copies-link.py index 12faed38..55c2b57f 100644 --- a/test/copies-link/gyptest-copies-link.py +++ b/test/copies-link/gyptest-copies-link.py @@ -12,6 +12,6 @@ test.run_gyp('copies-link.gyp', chdir='src') test.relocate('src', 'relocate/src') -test.build_default('copies-link.gyp', chdir='relocate/src') +test.build('copies-link.gyp', chdir='relocate/src') test.pass_test() diff --git a/test/copies/gyptest-all.py b/test/copies/gyptest-all.py index 934941b1..8c29b19c 100644 --- a/test/copies/gyptest-all.py +++ b/test/copies/gyptest-all.py @@ -12,7 +12,7 @@ test.run_gyp('copies.gyp', chdir='src') test.relocate('src', 'relocate/src') -test.build_all('copies.gyp', chdir='relocate/src') +test.build('copies.gyp', test.ALL, chdir='relocate/src') test.must_match(['relocate', 'src', 'copies-out', 'file1'], "file1 contents\n") diff --git a/test/copies/gyptest-default.py b/test/copies/gyptest-default.py index fdf36b61..2c396177 100644 --- a/test/copies/gyptest-default.py +++ b/test/copies/gyptest-default.py @@ -12,7 +12,7 @@ test.run_gyp('copies.gyp', chdir='src') test.relocate('src', 'relocate/src') -test.build_default('copies.gyp', chdir='relocate/src') +test.build('copies.gyp', chdir='relocate/src') test.must_match(['relocate', 'src', 'copies-out', 'file1'], "file1 contents\n") diff --git a/test/defines/gyptest-defines-env-regyp.py b/test/defines/gyptest-defines-env-regyp.py index 91ca859f..08616a48 100644 --- a/test/defines/gyptest-defines-env-regyp.py +++ b/test/defines/gyptest-defines-env-regyp.py @@ -22,7 +22,7 @@ finally: os.environ['GYP_DEFINES'] = '' del os.environ['GYP_DEFINES'] -test.run_build('defines.gyp') +test.build('defines.gyp') expect = """\ FOO is defined @@ -35,7 +35,7 @@ test.run_built_executable('defines', stdout=expect) test.sleep() test.write('defines.gyp', test.read('defines-env.gyp')) -test.build_all('defines.gyp') +test.build('defines.gyp', test.ALL) expect = """\ VALUE is 50 diff --git a/test/defines/gyptest-defines-env.py b/test/defines/gyptest-defines-env.py index 240b837a..a5152af3 100644 --- a/test/defines/gyptest-defines-env.py +++ b/test/defines/gyptest-defines-env.py @@ -16,7 +16,7 @@ try: finally: del os.environ['GYP_DEFINES'] -test.run_build('defines-env.gyp') +test.build('defines-env.gyp') expect = """\ VALUE is 10 @@ -34,7 +34,7 @@ finally: test.sleep() test.touch('defines.c') -test.run_build('defines-env.gyp') +test.build('defines-env.gyp') expect = """\ VALUE is 25 @@ -52,7 +52,7 @@ finally: test.sleep() test.touch('defines.c') -test.run_build('defines-env.gyp') +test.build('defines-env.gyp') expect = """\ VALUE is 5 @@ -70,7 +70,7 @@ finally: test.sleep() test.touch('defines.c') -test.run_build('defines-env.gyp') +test.build('defines-env.gyp') expect = """\ VALUE is 45 diff --git a/test/defines/gyptest-defines.py b/test/defines/gyptest-defines.py index cd9107d7..b896690d 100644 --- a/test/defines/gyptest-defines.py +++ b/test/defines/gyptest-defines.py @@ -10,7 +10,7 @@ test = TestGyp.TestGyp() test.run_gyp('defines.gyp') -test.run_build('defines.gyp') +test.build('defines.gyp') expect = """\ FOO is defined diff --git a/test/dependencies/gyptest-extra-targets.py b/test/dependencies/gyptest-extra-targets.py index e3d996ff..0c8ac17c 100644 --- a/test/dependencies/gyptest-extra-targets.py +++ b/test/dependencies/gyptest-extra-targets.py @@ -12,6 +12,6 @@ test.run_gyp('extra_targets.gyp') # This should fail if it tries to build 'c_unused' since 'c/c.c' has a syntax # error and won't compile. -test.build_all('extra_targets.gyp') +test.build('extra_targets.gyp', test.ALL) test.pass_test() diff --git a/test/dependencies/gyptest-lib-only.py b/test/dependencies/gyptest-lib-only.py index 03352b85..235eee22 100755 --- a/test/dependencies/gyptest-lib-only.py +++ b/test/dependencies/gyptest-lib-only.py @@ -11,7 +11,7 @@ test = TestGyp.TestGyp() test.run_gyp('lib_only.gyp') -test.build_all('lib_only.gyp') +test.build('lib_only.gyp', test.ALL) # Make doesn't put static libs in a common 'lib' directory, like it does with # shared libs, so check in the obj path corresponding to the source path. diff --git a/test/dependency-copy/gyptest-copy.py b/test/dependency-copy/gyptest-copy.py index bba28d62..6fb0492f 100644 --- a/test/dependency-copy/gyptest-copy.py +++ b/test/dependency-copy/gyptest-copy.py @@ -10,7 +10,7 @@ test = TestGyp.TestGyp() test.run_gyp('copies.gyp', chdir='src') -test.build_target('copies.gyp', 'proj2', chdir='src') +test.build('copies.gyp', 'proj2', chdir='src') test.run_built_executable('proj1', chdir='src', diff --git a/test/generator-output/gyptest-actions.py b/test/generator-output/gyptest-actions.py index 3ad3d6ef..54294c12 100644 --- a/test/generator-output/gyptest-actions.py +++ b/test/generator-output/gyptest-actions.py @@ -33,7 +33,7 @@ test.writable(test.workpath('relocate/actions/subdir1/actions-out'), True) test.writable(test.workpath('relocate/actions/subdir2/build'), True) test.writable(test.workpath('relocate/actions/subdir2/actions-out'), True) -test.build_all('actions.gyp', chdir='relocate/gypfiles') +test.build('actions.gyp', test.ALL, chdir='relocate/gypfiles') expect = """\ Hello from program.c diff --git a/test/generator-output/gyptest-copies.py b/test/generator-output/gyptest-copies.py index 35e9a374..6eac773f 100644 --- a/test/generator-output/gyptest-copies.py +++ b/test/generator-output/gyptest-copies.py @@ -26,7 +26,7 @@ test.writable(test.workpath('relocate/copies/copies-out'), True) test.writable(test.workpath('relocate/copies/subdir/build'), True) test.writable(test.workpath('relocate/copies/subdir/copies-out'), True) -test.build_all('copies.gyp', chdir='relocate/gypfiles') +test.build('copies.gyp', test.ALL, chdir='relocate/gypfiles') test.must_match(['relocate', 'copies', 'copies-out', 'file1'], "file1 contents\n") diff --git a/test/generator-output/gyptest-relocate.py b/test/generator-output/gyptest-relocate.py index 38cfcdb8..b394021d 100644 --- a/test/generator-output/gyptest-relocate.py +++ b/test/generator-output/gyptest-relocate.py @@ -27,7 +27,7 @@ test.writable(test.workpath('relocate/src/build'), True) test.writable(test.workpath('relocate/src/subdir2/build'), True) test.writable(test.workpath('relocate/src/subdir3/build'), True) -test.build_all('prog1.gyp', chdir='relocate/gypfiles') +test.build('prog1.gyp', test.ALL, chdir='relocate/gypfiles') chdir = 'relocate/gypfiles' diff --git a/test/generator-output/gyptest-rules.py b/test/generator-output/gyptest-rules.py index 97a627c1..9261d757 100644 --- a/test/generator-output/gyptest-rules.py +++ b/test/generator-output/gyptest-rules.py @@ -26,7 +26,7 @@ test.writable(test.workpath('relocate/rules/subdir1/build'), True) test.writable(test.workpath('relocate/rules/subdir2/build'), True) test.writable(test.workpath('relocate/rules/subdir2/rules-out'), True) -test.build_all('rules.gyp', chdir='relocate/gypfiles') +test.build('rules.gyp', test.ALL, chdir='relocate/gypfiles') expect = """\ Hello from program.c diff --git a/test/generator-output/gyptest-subdir2-deep.py b/test/generator-output/gyptest-subdir2-deep.py index 0cafd200..35c43111 100644 --- a/test/generator-output/gyptest-subdir2-deep.py +++ b/test/generator-output/gyptest-subdir2-deep.py @@ -19,7 +19,7 @@ test.run_gyp('deeper.gyp', '--generator-output=' + test.workpath('gypfiles'), chdir='src/subdir2/deeper') -test.build_all('deeper.gyp', chdir='gypfiles') +test.build('deeper.gyp', test.ALL, chdir='gypfiles') chdir = 'gypfiles' diff --git a/test/generator-output/gyptest-top-all.py b/test/generator-output/gyptest-top-all.py index a79357cf..767db142 100644 --- a/test/generator-output/gyptest-top-all.py +++ b/test/generator-output/gyptest-top-all.py @@ -21,7 +21,7 @@ test.writable(test.workpath('src/build'), True) test.writable(test.workpath('src/subdir2/build'), True) test.writable(test.workpath('src/subdir3/build'), True) -test.build_all('prog1.gyp', chdir='gypfiles') +test.build('prog1.gyp', test.ALL, chdir='gypfiles') chdir = 'gypfiles' diff --git a/test/hello/gyptest-all.py b/test/hello/gyptest-all.py index 04460a97..8da808f2 100644 --- a/test/hello/gyptest-all.py +++ b/test/hello/gyptest-all.py @@ -11,7 +11,7 @@ test = TestGyp.TestGyp() test.run_gyp('hello.gyp') -test.build_all('hello.gyp') +test.build('hello.gyp', test.ALL) test.run_built_executable('hello', stdout="Hello, world!\n") diff --git a/test/hello/gyptest-default.py b/test/hello/gyptest-default.py index 7f659149..5e77a809 100644 --- a/test/hello/gyptest-default.py +++ b/test/hello/gyptest-default.py @@ -11,7 +11,7 @@ test = TestGyp.TestGyp() test.run_gyp('hello.gyp') -test.build_default('hello.gyp') +test.build('hello.gyp') test.run_built_executable('hello', stdout="Hello, world!\n") diff --git a/test/hello/gyptest-disable-regyp.py b/test/hello/gyptest-disable-regyp.py index ffd1276d..8114ef40 100644 --- a/test/hello/gyptest-disable-regyp.py +++ b/test/hello/gyptest-disable-regyp.py @@ -11,7 +11,7 @@ test = TestGyp.TestGyp() test.run_gyp('hello.gyp', '-Gauto_regeneration=0') -test.build_all('hello.gyp') +test.build('hello.gyp', test.ALL) test.run_built_executable('hello', stdout="Hello, world!\n") @@ -20,7 +20,7 @@ test.run_built_executable('hello', stdout="Hello, world!\n") test.sleep() test.write('hello.gyp', test.read('hello2.gyp')) -test.build_all('hello.gyp') +test.build('hello.gyp', test.ALL) # Should still be the old executable, as regeneration was disabled. test.run_built_executable('hello', stdout="Hello, world!\n") diff --git a/test/hello/gyptest-regyp.py b/test/hello/gyptest-regyp.py index a4b9c131..6d16ac57 100644 --- a/test/hello/gyptest-regyp.py +++ b/test/hello/gyptest-regyp.py @@ -12,7 +12,7 @@ test = TestGyp.TestGyp(formats=['make']) test.run_gyp('hello.gyp') -test.build_all('hello.gyp') +test.build('hello.gyp', test.ALL) test.run_built_executable('hello', stdout="Hello, world!\n") @@ -21,7 +21,7 @@ test.run_built_executable('hello', stdout="Hello, world!\n") test.sleep() test.write('hello.gyp', test.read('hello2.gyp')) -test.build_all('hello.gyp') +test.build('hello.gyp', test.ALL) test.run_built_executable('hello', stdout="Hello, two!\n") diff --git a/test/hello/gyptest-target.py b/test/hello/gyptest-target.py index 0cbafb76..ffb67277 100755 --- a/test/hello/gyptest-target.py +++ b/test/hello/gyptest-target.py @@ -11,7 +11,7 @@ test = TestGyp.TestGyp() test.run_gyp('hello.gyp') -test.build_target('hello.gyp', 'hello') +test.build('hello.gyp', 'hello') test.run_built_executable('hello', stdout="Hello, world!\n") diff --git a/test/include_dirs/gyptest-all.py b/test/include_dirs/gyptest-all.py index cc22ce28..52f307eb 100644 --- a/test/include_dirs/gyptest-all.py +++ b/test/include_dirs/gyptest-all.py @@ -12,7 +12,7 @@ test.run_gyp('includes.gyp', chdir='src') test.relocate('src', 'relocate/src') -test.build_all('includes.gyp', chdir='relocate/src') +test.build('includes.gyp', test.ALL, chdir='relocate/src') expect = """\ Hello from includes.c diff --git a/test/include_dirs/gyptest-default.py b/test/include_dirs/gyptest-default.py index ac96684d..d70dbb88 100644 --- a/test/include_dirs/gyptest-default.py +++ b/test/include_dirs/gyptest-default.py @@ -12,7 +12,7 @@ test.run_gyp('includes.gyp', chdir='src') test.relocate('src', 'relocate/src') -test.build_all('includes.gyp', chdir='relocate/src') +test.build('includes.gyp', test.ALL, chdir='relocate/src') expect = """\ Hello from includes.c diff --git a/test/lib/TestGyp.py b/test/lib/TestGyp.py index c5cfbd53..b29db9e9 100644 --- a/test/lib/TestGyp.py +++ b/test/lib/TestGyp.py @@ -201,24 +201,15 @@ class TestGypBase(TestCommon.TestCommon): # Abstract methods to be defined by format-specific subclasses. # - def build_all(self, gyp_file, **kw): - """ - Runs an "all" build of the configuration generated from the - specified gyp_file. - """ - raise NotImplementedError - - def build_default(self, gyp_file, **kw): - """ - Runs the default build of the configuration generated from the - specified gyp_file. - """ - raise NotImplementedError - - def build_target(self, gyp_file, target, **kw): + def build(self, gyp_file, target=None, **kw): """ Runs a build of the specified target against the configuration generated from the specified gyp_file. + + A 'target' argument of None or the special value TestGyp.DEFAULT + specifies the default argument for the underlying build tool. + A 'target' argument of TestGyp.ALL specifies the 'all' target + (if any) of the underlying build tool. """ raise NotImplementedError @@ -236,7 +227,7 @@ class TestGypBase(TestCommon.TestCommon): """ Verifies that a build of the specified target is up to date. - The subclass should implement this by calling run_build() + The subclass should implement this by calling build() (or a reasonable equivalent), checking whatever conditions will tell it the build was an "up to date" null build, and failing if it isn't. @@ -259,33 +250,28 @@ class TestGypMake(TestGypBase): format = 'make' build_tool_list = ['make'] ALL = 'all' - def build_all(self, gyp_file, **kw): - """ - Builds the Make 'all' target to build all targets for the Makefiles - generated from the specified gyp_file. - """ - self.run_build(gyp_file, 'all', **kw) - def build_default(self, gyp_file, **kw): - """ - Runs Make with no additional command-line arguments to get the - default build for the Makefiles generated from the specified gyp_file. - """ - self.run_build(gyp_file, **kw) - def build_target(self, gyp_file, target, **kw): - """ - Runs a Make build with the specified target on the command line - to build just that target using the Makefile generated from the - specified gyp_file. - """ - self.run_build(gyp_file, target, **kw) - def run_build(self, gyp_file, *args, **kw): + def build(self, gyp_file, target=None, **kw): """ Runs a Make build using the Makefiles generated from the specified gyp_file. """ + arguments = kw.get('arguments', []) if self.configuration: - args += ('BUILDTYPE=' + self.configuration,) - return self.run(program=self.build_tool, arguments=args, **kw) + arguments.append('BUILDTYPE=' + self.configuration) + if target not in (None, self.DEFAULT): + arguments.append(target) + kw['arguments'] = arguments + return self.run(program=self.build_tool, **kw) + def up_to_date(self, gyp_file, target=None, **kw): + """ + Verifies that a build of the specified Make target is up to date. + """ + if target in (None, self.DEFAULT): + message_target = 'all' + else: + message_target = target + kw['stdout'] = "make: Nothing to be done for `%s'.\n" % message_target + return self.build(gyp_file, target, **kw) def run_built_executable(self, name, *args, **kw): """ Runs an executable built by Make. @@ -311,17 +297,6 @@ class TestGypMake(TestGypBase): lib_path = self.workpath('out', configuration, libdir, self.lib_ + name + self._lib) self.must_not_exist(lib_path) - def up_to_date(self, gyp_file, target=None, **kw): - """ - Verifies that a build of the specified Make target is up to date. - """ - if target == self.DEFAULT: - args = () - target = 'all' - else: - args = (target,) - kw['stdout'] = "make: Nothing to be done for `%s'.\n" % target - return self.run_build(gyp_file, *args, **kw) class TestGypMSVS(TestGypBase): @@ -340,29 +315,6 @@ class TestGypMSVS(TestGypBase): # Directly executing devenv.exe only sends output to BuildLog.htm. build_tool_list = [None, 'devenv.com'] - def build_all(self, gyp_file, **kw): - """ - Runs devenv.com with no target-specific options to get the "all" - build for the Visual Studio configuration generated from the - specified gyp_file. - - (NOTE: This is the same as the default, our generated Visual Studio - configuration doesn't create an explicit "all" target.) - """ - return self.run_build(gyp_file, **kw) - def build_default(self, gyp_file, **kw): - """ - Runs devenv.com with no target-specific options to get the default - build for the Visual Studio configuration generated from the - specified gyp_file. - """ - return self.run_build(gyp_file, **kw) - def build_target(self, gyp_file, target, **kw): - """ - Uses the devenv.com /Project option to build the specified target with - the Visual Studio configuration generated from the specified gyp_file. - """ - return self.run_build(gyp_file, '/Project', target, **kw) def initialize_build_tool(self): """ Initializes the Visual Studio .build_tool parameter, searching %PATH% @@ -387,30 +339,29 @@ class TestGypMSVS(TestGypBase): if os.path.exists(bt): self.build_tool = bt break - def run_build(self, gyp_file, *args, **kw): + def build(self, gyp_file, target=None, **kw): """ Runs a Visual Studio build using the configuration generated from the specified gyp_file. """ configuration = self.configuration or 'Default' - args = (gyp_file.replace('.gyp', '.sln'), '/Build', configuration) + args + arguments = kw.get('arguments', []) + arguments.extend([gyp_file.replace('.gyp', '.sln'), + '/Build', + configuration]) + # Note: the Visual Studio generator doesn't add an explicit 'all' + # target, so we just treat it the same as the default. + if target not in (None, self.ALL, self.DEFAULT): + arguments.extend(['/Project', target]) if self.configuration: - args += ('/ProjectConfig', self.configuration,) - return self.run(program=self.build_tool, arguments=args, **kw) - def run_built_executable(self, name, *args, **kw): - """ - Runs an executable built by Visual Studio. - """ - configuration = self.configuration or 'Default' - # Enclosing the name in a list avoids prepending the original dir. - program = [os.path.join(configuration, '%s.exe' % name)] - return self.run(program=program, *args, **kw) + arguments.extend(['/ProjectConfig', self.configuration]) + kw['arguments'] = arguments + return self.run(program=self.build_tool, **kw) def up_to_date(self, gyp_file, target=None, **kw): """ Verifies that a build of the specified Visual Studio target is up to date. """ - args = () - result = self.run_build(gyp_file, *args, **kw) + result = self.build(gyp_file, target, **kw) if not result: stdout = self.stdout() m = self.up_to_date_re.search(stdout) @@ -418,6 +369,14 @@ class TestGypMSVS(TestGypBase): self.report_not_up_to_date() self.fail_test() return result + def run_built_executable(self, name, *args, **kw): + """ + Runs an executable built by Visual Studio. + """ + configuration = self.configuration or 'Default' + # Enclosing the name in a list avoids prepending the original dir. + program = [os.path.join(configuration, '%s.exe' % name)] + return self.run(program=program, *args, **kw) def built_lib_must_exist(self, name, *args, **kw): configuration = self.configuration or 'Default' lib_path = self.workpath(configuration, 'lib', self.lib_ + name + self._lib) @@ -435,52 +394,37 @@ class TestGypSCons(TestGypBase): format = 'scons' build_tool_list = ['scons', 'scons.py'] ALL = 'all' - def build_all(self, gyp_file, **kw): - """ - Builds the scons 'all' target to build all targets for the - SCons configuration generated from the specified gyp_file. + def build(self, gyp_file, target=None, **kw): """ - self.run_build(gyp_file, 'all', **kw) - def build_default(self, gyp_file, **kw): - """ - Runs scons with no additional command-line arguments to get the - default build for the SCons configuration generated from the + Runs a scons build using the SCons configuration generated from the specified gyp_file. """ - self.run_build(gyp_file, **kw) - def build_target(self, gyp_file, target, **kw): - """ - Runs a scons build with the specified target on the command line to - build just that target using the SCons configuration generated from - the specified gyp_file. - """ - self.run_build(gyp_file, target, **kw) + arguments = kw.get('arguments', []) + dirname = os.path.dirname(gyp_file) + if dirname: + arguments.extend(['-C', dirname]) + if self.configuration: + arguments.append('--mode=' + self.configuration) + if target not in (None, self.DEFAULT): + arguments.append(target) + kw['arguments'] = arguments + return self.run(program=self.build_tool, **kw) def up_to_date(self, gyp_file, target=None, **kw): """ Verifies that a build of the specified SCons target is up to date. """ - up_to_date_lines = [] - if target == self.DEFAULT: + if target in (None, self.DEFAULT): up_to_date_targets = 'all' - args = ('-Q',) else: up_to_date_targets = target - args = ('-Q', target) + up_to_date_lines = [] for arg in up_to_date_targets.split(): up_to_date_lines.append("scons: `%s' is up to date.\n" % arg) kw['stdout'] = ''.join(up_to_date_lines) - return self.run_build(gyp_file, *args, **kw) - def run_build(self, gyp_file, *args, **kw): - """ - Runs a scons build using the SCons configuration generated from the - specified gyp_file. - """ - dirname = os.path.dirname(gyp_file) - if dirname: - args += ('-C', dirname) - if self.configuration: - args += ('--mode=' + self.configuration,) - return self.run(program=self.build_tool, arguments=args, **kw) + arguments = kw.get('arguments', []) + arguments.append('-Q') + kw['arguments'] = arguments + return self.build(gyp_file, target, **kw) def run_built_executable(self, name, *args, **kw): """ Runs an executable built by scons. @@ -525,36 +469,37 @@ class TestGypXcode(TestGypBase): up_to_date_ending = 'Checking Dependencies...\n** BUILD SUCCEEDED **\n' - def build_all(self, gyp_file, **kw): - """ - Uses the xcodebuild -alltargets option to build all targets for the - .xcodeproj generated from the specified gyp_file. - """ - return self.run_build(gyp_file, '-alltargets', **kw) - def build_default(self, gyp_file, **kw): - """ - Runs xcodebuild with no target-specific options to get the default - build for the .xcodeproj generated from the specified gyp_file. - """ - return self.run_build(gyp_file, **kw) - def build_target(self, gyp_file, target, **kw): - """ - Uses the xcodebuild -target option to build the specified target - with the .xcodeproj generated from the specified gyp_file. - """ - return self.run_build(gyp_file, '-target', target, **kw) - def run_build(self, gyp_file, *args, **kw): + def build(self, gyp_file, target=None, **kw): """ Runs an xcodebuild using the .xcodeproj generated from the specified gyp_file. """ - args = ('-project', gyp_file.replace('.gyp', '.xcodeproj')) + args + arguments = kw.get('arguments', []) + arguments.extend(['-project', gyp_file.replace('.gyp', '.xcodeproj')]) + if target == self.ALL: + arguments.append('-alltargets',) + elif target not in (None, self.DEFAULT): + arguments.extend(['-target', target]) if self.configuration: - args += ('-configuration', self.configuration) + arguments.extend(['-configuration', self.configuration]) symroot = kw.get('SYMROOT', '$SRCROOT/build') if symroot: - args += ('SYMROOT='+symroot,) + args - return self.run(program=self.build_tool, arguments=args, **kw) + arguments.append('SYMROOT='+symroot) + kw['arguments'] = arguments + return self.run(program=self.build_tool, **kw) + def up_to_date(self, gyp_file, target=None, **kw): + """ + Verifies that a build of the specified Xcode target is up to date. + """ + result = self.build(gyp_file, target, **kw) + if not result: + output = self.stdout() + for expression in self.strip_up_to_date_expressions: + output = expression.sub('', output) + if not output.endswith(self.up_to_date_ending): + self.report_not_up_to_date() + self.fail_test() + return result def run_built_executable(self, name, *args, **kw): """ Runs an executable built by xcodebuild. @@ -574,25 +519,6 @@ class TestGypXcode(TestGypBase): lib_path = self.workpath('build', configuration, self.lib_ + name + self._lib) self.must_not_exist(lib_path) - def up_to_date(self, gyp_file, target=None, **kw): - """ - Verifies that a build of the specified Xcode target is up to date. - """ - if target == self.DEFAULT: - args = () - elif target == self.ALL: - args = ('-alltargets',) - else: - args = ('-target', target) - result = self.run_build(gyp_file, *args, **kw) - if not result: - output = self.stdout() - for expression in self.strip_up_to_date_expressions: - output = expression.sub('', output) - if not output.endswith(self.up_to_date_ending): - self.report_not_up_to_date() - self.fail_test() - return result format_class_list = [ diff --git a/test/library/gyptest-shared.py b/test/library/gyptest-shared.py index 8c0bedc4..107c4dce 100644 --- a/test/library/gyptest-shared.py +++ b/test/library/gyptest-shared.py @@ -17,7 +17,7 @@ test.run_gyp('library.gyp', test.relocate('src', 'relocate/src') -test.build_all('library.gyp', chdir='relocate/src') +test.build('library.gyp', test.ALL, chdir='relocate/src') expect = """\ Hello from program.c @@ -39,7 +39,7 @@ contents = test.read('relocate/src/program.c') contents = contents.replace('Hello', 'Hello again') test.write('relocate/src/program.c', contents) -test.build_all('library.gyp', chdir='relocate/src') +test.build('library.gyp', test.ALL, chdir='relocate/src') expect = """\ Hello again from program.c @@ -66,7 +66,7 @@ test.write('relocate/src/program.c', contents) # on the generated .vcproj file itself. test.touch('relocate/src/lib2.c') -test.build_all('library.gyp', chdir='relocate/src') +test.build('library.gyp', test.ALL, chdir='relocate/src') expect = """\ Hello again again from program.c diff --git a/test/library/gyptest-static.py b/test/library/gyptest-static.py index 0998eb9d..e5c5117b 100644 --- a/test/library/gyptest-static.py +++ b/test/library/gyptest-static.py @@ -17,7 +17,7 @@ test.run_gyp('library.gyp', test.relocate('src', 'relocate/src') -test.build_all('library.gyp', chdir='relocate/src') +test.build('library.gyp', test.ALL, chdir='relocate/src') expect = """\ Hello from program.c @@ -39,7 +39,7 @@ contents = test.read('relocate/src/program.c') contents = contents.replace('Hello', 'Hello again') test.write('relocate/src/program.c', contents) -test.build_all('library.gyp', chdir='relocate/src') +test.build('library.gyp', test.ALL, chdir='relocate/src') expect = """\ Hello again from program.c @@ -66,7 +66,7 @@ test.write('relocate/src/program.c', contents) # on the generated .vcproj file itself. test.touch('relocate/src/lib2.c') -test.build_all('library.gyp', chdir='relocate/src') +test.build('library.gyp', test.ALL, chdir='relocate/src') expect = """\ Hello again again from program.c diff --git a/test/module/gyptest-default.py b/test/module/gyptest-default.py index b4fbd67d..988c5b18 100644 --- a/test/module/gyptest-default.py +++ b/test/module/gyptest-default.py @@ -12,7 +12,7 @@ test = TestGyp.TestGyp() test.run_gyp('module.gyp', chdir='src') -test.build_all('module.gyp', chdir='src') +test.build('module.gyp', test.ALL, chdir='src') expect = """\ Hello from program.c diff --git a/test/multiple-targets/gyptest-all.py b/test/multiple-targets/gyptest-all.py index c679326b..2da237d7 100644 --- a/test/multiple-targets/gyptest-all.py +++ b/test/multiple-targets/gyptest-all.py @@ -13,7 +13,7 @@ test.relocate('src', 'relocate/src') # TODO(sgk): remove stderr=None when the --generator-output= support # gets rid of the scons warning -test.build_all('multiple.gyp', chdir='relocate/src', stderr=None) +test.build('multiple.gyp', test.ALL, chdir='relocate/src', stderr=None) expect1 = """\ hello from prog1.c diff --git a/test/multiple-targets/gyptest-default.py b/test/multiple-targets/gyptest-default.py index baebfdc5..433fea22 100644 --- a/test/multiple-targets/gyptest-default.py +++ b/test/multiple-targets/gyptest-default.py @@ -13,7 +13,7 @@ test.relocate('src', 'relocate/src') # TODO(sgk): remove stderr=None when the --generator-output= support # gets rid of the scons warning -test.build_default('multiple.gyp', chdir='relocate/src', stderr=None) +test.build('multiple.gyp', chdir='relocate/src', stderr=None) expect1 = """\ hello from prog1.c diff --git a/test/rules/gyptest-all.py b/test/rules/gyptest-all.py index d8eb9614..ee6b0404 100644 --- a/test/rules/gyptest-all.py +++ b/test/rules/gyptest-all.py @@ -12,7 +12,7 @@ test.run_gyp('actions.gyp', chdir='src') test.relocate('src', 'relocate/src') -test.build_all('actions.gyp', chdir='relocate/src') +test.build('actions.gyp', test.ALL, chdir='relocate/src') expect = """\ Hello from program.c diff --git a/test/rules/gyptest-default.py b/test/rules/gyptest-default.py index f8a494aa..714b4e88 100644 --- a/test/rules/gyptest-default.py +++ b/test/rules/gyptest-default.py @@ -12,7 +12,7 @@ test.run_gyp('actions.gyp', chdir='src') test.relocate('src', 'relocate/src') -test.build_default('actions.gyp', chdir='relocate/src') +test.build('actions.gyp', chdir='relocate/src') expect = """\ Hello from program.c diff --git a/test/same-name/gyptest-all.py b/test/same-name/gyptest-all.py index 3d290b90..ce96e92d 100644 --- a/test/same-name/gyptest-all.py +++ b/test/same-name/gyptest-all.py @@ -12,7 +12,7 @@ test.run_gyp('all.gyp', chdir='src') test.relocate('src', 'relocate/src') -test.build_all('all.gyp', chdir='relocate/src') +test.build('all.gyp', test.ALL, chdir='relocate/src') expect1 = """\ Hello from prog1.c diff --git a/test/same-name/gyptest-default.py b/test/same-name/gyptest-default.py index 3201a590..581fe93b 100644 --- a/test/same-name/gyptest-default.py +++ b/test/same-name/gyptest-default.py @@ -12,7 +12,7 @@ test.run_gyp('all.gyp', chdir='src') test.relocate('src', 'relocate/src') -test.build_default('all.gyp', chdir='relocate/src') +test.build('all.gyp', chdir='relocate/src') expect1 = """\ Hello from prog1.c diff --git a/test/scons_tools/gyptest-tools.py b/test/scons_tools/gyptest-tools.py index a2d3534e..255d3177 100755 --- a/test/scons_tools/gyptest-tools.py +++ b/test/scons_tools/gyptest-tools.py @@ -11,7 +11,7 @@ test = TestGyp.TestGyp() test.run_gyp('tools.gyp') -test.build_all('tools.gyp') +test.build('tools.gyp', test.ALL) if test.format == 'scons': expect = "Hello, world!\n" diff --git a/test/sibling/gyptest-all.py b/test/sibling/gyptest-all.py index 75f97321..e0d19629 100644 --- a/test/sibling/gyptest-all.py +++ b/test/sibling/gyptest-all.py @@ -9,7 +9,7 @@ test = TestGyp.TestGyp() test.run_gyp('build/all.gyp', chdir='src') -test.build_all('build/all.gyp', chdir='src') +test.build('build/all.gyp', test.ALL, chdir='src') chdir = 'src/build' diff --git a/test/sibling/gyptest-relocate.py b/test/sibling/gyptest-relocate.py index 82d3ae39..9e741552 100644 --- a/test/sibling/gyptest-relocate.py +++ b/test/sibling/gyptest-relocate.py @@ -11,7 +11,7 @@ test.run_gyp('build/all.gyp', chdir='src') test.relocate('src', 'relocate/src') -test.build_all('build/all.gyp', chdir='relocate/src') +test.build('build/all.gyp', test.ALL, chdir='relocate/src') chdir = 'relocate/src/build' diff --git a/test/subdirectory/gyptest-SYMROOT-all.py b/test/subdirectory/gyptest-SYMROOT-all.py index 3b7ce014..3194220e 100644 --- a/test/subdirectory/gyptest-SYMROOT-all.py +++ b/test/subdirectory/gyptest-SYMROOT-all.py @@ -20,7 +20,7 @@ test.run_gyp('prog1.gyp', '-Dset_symroot=1', '--depth=.', chdir='src') test.relocate('src', 'relocate/src') # Suppress the test infrastructure's setting SYMROOT on the command line. -test.build_all('prog1.gyp', SYMROOT=None, chdir='relocate/src') +test.build('prog1.gyp', test.ALL, SYMROOT=None, chdir='relocate/src') test.run_built_executable('prog1', stdout="Hello from prog1.c\n", diff --git a/test/subdirectory/gyptest-SYMROOT-default.py b/test/subdirectory/gyptest-SYMROOT-default.py index ed070c0f..453c5a16 100644 --- a/test/subdirectory/gyptest-SYMROOT-default.py +++ b/test/subdirectory/gyptest-SYMROOT-default.py @@ -20,7 +20,7 @@ test.run_gyp('prog1.gyp', '-Dset_symroot=1', '--depth=.', chdir='src') test.relocate('src', 'relocate/src') # Suppress the test infrastructure's setting SYMROOT on the command line. -test.build_default('prog1.gyp', SYMROOT=None, chdir='relocate/src') +test.build('prog1.gyp', SYMROOT=None, chdir='relocate/src') test.run_built_executable('prog1', stdout="Hello from prog1.c\n", diff --git a/test/subdirectory/gyptest-subdir-all.py b/test/subdirectory/gyptest-subdir-all.py index 7459d220..8e62ae62 100644 --- a/test/subdirectory/gyptest-subdir-all.py +++ b/test/subdirectory/gyptest-subdir-all.py @@ -14,7 +14,7 @@ test.run_gyp('prog1.gyp', chdir='src') test.relocate('src', 'relocate/src') -test.build_all('prog2.gyp', chdir='relocate/src/subdir') +test.build('prog2.gyp', test.ALL, chdir='relocate/src/subdir') test.must_not_exist('relocate/src/prog1'+test._exe) diff --git a/test/subdirectory/gyptest-subdir-default.py b/test/subdirectory/gyptest-subdir-default.py index f016b6f3..9f1556e6 100644 --- a/test/subdirectory/gyptest-subdir-default.py +++ b/test/subdirectory/gyptest-subdir-default.py @@ -14,7 +14,7 @@ test.run_gyp('prog1.gyp', chdir='src') test.relocate('src', 'relocate/src') -test.build_default('prog2.gyp', chdir='relocate/src/subdir') +test.build('prog2.gyp', chdir='relocate/src/subdir') test.must_not_exist('relocate/src/prog1'+test._exe) diff --git a/test/subdirectory/gyptest-subdir2-deep.py b/test/subdirectory/gyptest-subdir2-deep.py index 719e5174..9c738db8 100644 --- a/test/subdirectory/gyptest-subdir2-deep.py +++ b/test/subdirectory/gyptest-subdir2-deep.py @@ -12,7 +12,7 @@ test.run_gyp('prog3.gyp', chdir='src/subdir/subdir2') test.relocate('src', 'relocate/src') -test.build_all('prog3.gyp', chdir='relocate/src/subdir/subdir2') +test.build('prog3.gyp', test.ALL, chdir='relocate/src/subdir/subdir2') test.run_built_executable('prog3', chdir='relocate/src/subdir/subdir2', diff --git a/test/subdirectory/gyptest-top-all.py b/test/subdirectory/gyptest-top-all.py index 446996d3..4bab1e49 100644 --- a/test/subdirectory/gyptest-top-all.py +++ b/test/subdirectory/gyptest-top-all.py @@ -22,7 +22,7 @@ test.run_gyp('prog1.gyp', chdir='src') test.relocate('src', 'relocate/src') -test.build_all('prog1.gyp', chdir='relocate/src') +test.build('prog1.gyp', test.ALL, chdir='relocate/src') test.run_built_executable('prog1', stdout="Hello from prog1.c\n", diff --git a/test/subdirectory/gyptest-top-default.py b/test/subdirectory/gyptest-top-default.py index b8e33d29..170537ed 100644 --- a/test/subdirectory/gyptest-top-default.py +++ b/test/subdirectory/gyptest-top-default.py @@ -22,7 +22,7 @@ test.run_gyp('prog1.gyp', chdir='src') test.relocate('src', 'relocate/src') -test.build_default('prog1.gyp', chdir='relocate/src') +test.build('prog1.gyp', chdir='relocate/src') test.run_built_executable('prog1', stdout="Hello from prog1.c\n", diff --git a/test/toolsets/gyptest-toolsets.py b/test/toolsets/gyptest-toolsets.py index 4d74a117..56010cf3 100644 --- a/test/toolsets/gyptest-toolsets.py +++ b/test/toolsets/gyptest-toolsets.py @@ -11,7 +11,7 @@ test = TestGyp.TestGyp(formats=['make']) test.run_gyp('toolsets.gyp') -test.build_all('toolsets.gyp') +test.build('toolsets.gyp', test.ALL) test.run_built_executable('host-main', stdout="Host\n") test.run_built_executable('target-main', stdout="Target\n") diff --git a/test/variants/gyptest-variants.py b/test/variants/gyptest-variants.py index 2de4be14..f5c5ddf4 100644 --- a/test/variants/gyptest-variants.py +++ b/test/variants/gyptest-variants.py @@ -18,21 +18,21 @@ test.run_gyp('variants.gyp', chdir='src') test.relocate('src', 'relocate/src') -test.run_build('variants.gyp', chdir='relocate/src') +test.build('variants.gyp', chdir='relocate/src') test.run_built_executable('variants', chdir='relocate/src', stdout="Hello, world!\n") test.sleep() -test.run_build('variants.gyp', 'VARIANT1=1', chdir='relocate/src') +test.build('variants.gyp', 'VARIANT1=1', chdir='relocate/src') test.run_built_executable('variants', chdir='relocate/src', stdout="Hello from VARIANT1\n") test.sleep() -test.run_build('variants.gyp', 'VARIANT2=1', chdir='relocate/src') +test.build('variants.gyp', 'VARIANT2=1', chdir='relocate/src') test.run_built_executable('variants', chdir='relocate/src', |