| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright 2014 Google Inc. | 3 # Copyright 2014 Google Inc. |
| 4 # | 4 # |
| 5 # Use of this source code is governed by a BSD-style license that can be | 5 # Use of this source code is governed by a BSD-style license that can be |
| 6 # found in the LICENSE file. | 6 # found in the LICENSE file. |
| 7 | 7 |
| 8 """ | 8 """ |
| 9 Test generate_user_config.py. | 9 Test generate_user_config.py. |
| 10 """ | 10 """ |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 def generate_dummy_user_config(original_sk_user_config, | 34 def generate_dummy_user_config(original_sk_user_config, |
| 35 require_sk_user_config, target_dir): | 35 require_sk_user_config, target_dir): |
| 36 # Add an arbitrary set of defines | 36 # Add an arbitrary set of defines |
| 37 defines = [ 'SK_BUILD_FOR_ANDROID', | 37 defines = [ 'SK_BUILD_FOR_ANDROID', |
| 38 'SK_BUILD_FOR_ANDROID_FRAMEWORK', | 38 'SK_BUILD_FOR_ANDROID_FRAMEWORK', |
| 39 'SK_SCALAR_IS_FLOAT', | 39 'SK_SCALAR_IS_FLOAT', |
| 40 'foo', | 40 'foo', |
| 41 'bar' ] | 41 'bar' ] |
| 42 gen_config(original_sk_user_config=original_sk_user_config, | 42 gen_config(original_sk_user_config=original_sk_user_config, |
| 43 require_sk_user_config=require_sk_user_config, | 43 require_sk_user_config=require_sk_user_config, |
| 44 target_dir=target_dir, ordered_set=defines) | 44 target_dir=target_dir, defines=defines) |
| 45 | 45 |
| 46 | 46 |
| 47 class GenUserConfigTest(unittest.TestCase): | 47 class GenUserConfigTest(unittest.TestCase): |
| 48 | 48 |
| 49 def test_missing_sk_user_config(self): | 49 def test_missing_sk_user_config(self): |
| 50 tmp = tempfile.mkdtemp() | 50 tmp = tempfile.mkdtemp() |
| 51 original = os.path.join(tmp, MISSING_FILENAME) | 51 original = os.path.join(tmp, MISSING_FILENAME) |
| 52 assert not os.path.exists(original) | 52 assert not os.path.exists(original) |
| 53 | 53 |
| 54 | 54 |
| 55 # With require_sk_user_config set to True, an AssertionError will be | 55 # With require_sk_user_config set to True, an AssertionError will be |
| 56 # thrown when original_sk_user_config is missing. | 56 # thrown when original_sk_user_config is missing. |
| 57 with self.assertRaises(AssertionError): | 57 with self.assertRaises(AssertionError): |
| 58 ordered_set = [ 'define' ] | 58 defines = [ 'define' ] |
| 59 gen_config(original_sk_user_config=original, | 59 gen_config(original_sk_user_config=original, |
| 60 require_sk_user_config=True, | 60 require_sk_user_config=True, |
| 61 target_dir=tmp, ordered_set=ordered_set) | 61 target_dir=tmp, defines=defines) |
| 62 | 62 |
| 63 # With require_sk_user_config set to False, it is okay for | 63 # With require_sk_user_config set to False, it is okay for |
| 64 # original_sk_user_config to be missing. | 64 # original_sk_user_config to be missing. |
| 65 generate_dummy_user_config(original_sk_user_config=original, | 65 generate_dummy_user_config(original_sk_user_config=original, |
| 66 require_sk_user_config=False, target_dir=tmp) | 66 require_sk_user_config=False, target_dir=tmp) |
| 67 actual_name = os.path.join(tmp, MISSING_FILENAME) | 67 actual_name = os.path.join(tmp, MISSING_FILENAME) |
| 68 utils.compare_to_expectation(actual_name=actual_name, | 68 utils.compare_to_expectation(actual_name=actual_name, |
| 69 expectation_name=MISSING_FILENAME, | 69 expectation_name=MISSING_FILENAME, |
| 70 assert_true=self.assertTrue, | 70 assert_true=self.assertTrue, |
| 71 msg=REBASELINE_MSG) | 71 msg=REBASELINE_MSG) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 99 parser = argparse.ArgumentParser() | 99 parser = argparse.ArgumentParser() |
| 100 parser.add_argument('-r', '--rebaseline', help='Rebaseline expectations.', | 100 parser.add_argument('-r', '--rebaseline', help='Rebaseline expectations.', |
| 101 action='store_true') | 101 action='store_true') |
| 102 args = parser.parse_args() | 102 args = parser.parse_args() |
| 103 | 103 |
| 104 if args.rebaseline: | 104 if args.rebaseline: |
| 105 rebaseline() | 105 rebaseline() |
| 106 else: | 106 else: |
| 107 main() | 107 main() |
| 108 | 108 |
| OLD | NEW |