From 797ae3e63911da734374df23b969775c75a219e9 Mon Sep 17 00:00:00 2001 From: Kongqun Yang Date: Tue, 19 Apr 2016 17:42:40 -0700 Subject: [PATCH] Copy packager_test.py to out directory on build - Disallow packager_test.py to be executed from source directory - Remove the building of packager target from packager_test.py. User need to make sure packager builds successfully before running the test. - Remove build_type parameter which is no longer needed Change-Id: I479d3c39b8d45730e5388d194069f1320fa5cd75 --- .travis.yml | 2 +- packager/app/test/packager_app.py | 9 +++------ packager/app/test/packager_test.py | 3 --- packager/app/test/test_env.py | 5 ++--- packager/packager.gyp | 13 +++++++++++++ 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8dbe9d070d..564af9b04f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ before_script: script: - ( find out/${BUILD_TYPE} -name "*_*test" | while read i ; do $i || exit ; done ) - - packager/app/test/packager_test.py -v --build_type ${BUILD_TYPE} + - out/${BUILD_TYPE}/packager_test.py -v before_deploy: - mv out/${BUILD_TYPE}/packager out/${BUILD_TYPE}/packager-${TRAVIS_OS_NAME} diff --git a/packager/app/test/packager_app.py b/packager/app/test/packager_app.py index 43306a747f..a5e9cd2c49 100644 --- a/packager/app/test/packager_app.py +++ b/packager/app/test/packager_app.py @@ -19,12 +19,9 @@ class PackagerApp(object): """Main integration class for testing the packager binary.""" def __init__(self): - self.build_dir = os.path.join(test_env.OUT_DIR, - test_env.options.build_type) - self.binary = os.path.join(self.build_dir, 'packager') - - def BuildSrc(self): - return subprocess.call(['ninja', '-C', self.build_dir]) + self.binary = os.path.join(test_env.SCRIPT_DIR, 'packager') + assert os.path.exists(self.binary), ('Please run from output directory, ' + 'e.g. out/Debug/packager_test.py') def DumpStreamInfo(self, stream): input_str = 'input=%s' % stream diff --git a/packager/app/test/packager_test.py b/packager/app/test/packager_test.py index ade8cbe1cf..0991089e43 100755 --- a/packager/app/test/packager_test.py +++ b/packager/app/test/packager_test.py @@ -35,9 +35,6 @@ class PackagerAppTest(unittest.TestCase): def tearDown(self): shutil.rmtree(self.tmp_dir) - def testBuildingCode(self): - self.assertEqual(0, self.packager.BuildSrc()) - def testVersion(self): self.assertRegexpMatches( self.packager.Version(), '^edash-packager version ' diff --git a/packager/app/test/test_env.py b/packager/app/test/test_env.py index bc4f86e715..b1ad15c8e6 100644 --- a/packager/app/test/test_env.py +++ b/packager/app/test/test_env.py @@ -20,13 +20,12 @@ import sys # Define static global objects and attributes. -SRC_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../..') -OUT_DIR = os.path.join(SRC_DIR, os.getenv('builddir_name', 'out')) +SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) +SRC_DIR = os.path.join(SCRIPT_DIR, os.pardir, os.pardir) # Parse arguments and calculate dynamic global objects and attributes. parser = argparse.ArgumentParser() -parser.add_argument('--build_type', default='Debug') parser.add_argument('--test_update_golden_files', default=0, type=int) aes = parser.add_argument_group( diff --git a/packager/packager.gyp b/packager/packager.gyp index e73bbedc73..6dbcf5f0b1 100644 --- a/packager/packager.gyp +++ b/packager/packager.gyp @@ -90,6 +90,19 @@ 'testing/gtest.gyp:gtest', ], }, + { + 'target_name': 'packager_test_py_copy', + 'type': 'none', + 'copies': [{ + 'destination': '<(PRODUCT_DIR)', + 'files': [ + 'app/test/packager_app.py', + 'app/test/packager_test.py', + 'app/test/test_env.py', + ], + }], + 'dependencies': ['packager'], + }, { 'target_name': 'packager_builder_tests', 'type': 'none',