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 gyp_to_android.py | 9 Test gyp_to_android.py |
10 """ | 10 """ |
11 | 11 |
12 import os | 12 import os |
13 import shutil | 13 import shutil |
14 import sys | 14 import sys |
15 import tempfile | 15 import tempfile |
16 import test_variables | 16 import test_variables |
17 import unittest | 17 import unittest |
18 | 18 |
19 # Path to android_framework_gyp | 19 sys.path.append(test_variables.ANDROID_DIR) |
20 sys.path.append(test_variables.GYP_GEN_DIR) | |
21 | 20 |
22 import android_framework_gyp | 21 import gyp_gen.android_framework_gyp |
23 | 22 |
24 GYPD_SUFFIX = ".gypd" | 23 GYPD_SUFFIX = ".gypd" |
25 GYP_SUFFIX = ".gyp" | 24 GYP_SUFFIX = ".gyp" |
26 GYPI_SUFFIX = ".gypi" | 25 GYPI_SUFFIX = ".gypi" |
27 OTHER_SUFFIX = ".txt" | 26 OTHER_SUFFIX = ".txt" |
28 | 27 |
29 class CleanGypdTest(unittest.TestCase): | 28 class CleanGypdTest(unittest.TestCase): |
30 | 29 |
31 def setUp(self): | 30 def setUp(self): |
32 self.__tmp_dir = tempfile.mkdtemp() | 31 self.__tmp_dir = tempfile.mkdtemp() |
(...skipping 21 matching lines...) Expand all Loading... |
54 | 53 |
55 def assert_file_does_not_exist(self, basename): | 54 def assert_file_does_not_exist(self, basename): |
56 """Assert that 'basename' does not exist in self.__tmp_dir. | 55 """Assert that 'basename' does not exist in self.__tmp_dir. |
57 """ | 56 """ |
58 full_name = os.path.join(self.__tmp_dir, basename) | 57 full_name = os.path.join(self.__tmp_dir, basename) |
59 self.assertFalse(os.path.exists(full_name)) | 58 self.assertFalse(os.path.exists(full_name)) |
60 | 59 |
61 def test_clean(self): | 60 def test_clean(self): |
62 """Test that clean_gypd_files() deletes .gypd files, and leaves others. | 61 """Test that clean_gypd_files() deletes .gypd files, and leaves others. |
63 """ | 62 """ |
64 android_framework_gyp.clean_gypd_files(self.__tmp_dir) | 63 gyp_gen.android_framework_gyp.clean_gypd_files(self.__tmp_dir) |
65 for i in range(self.__num_files): | 64 for i in range(self.__num_files): |
66 self.assert_file_exists('%s%s' % (str(i), GYPI_SUFFIX)) | 65 self.assert_file_exists('%s%s' % (str(i), GYPI_SUFFIX)) |
67 self.assert_file_exists('%s%s' % (str(i), GYP_SUFFIX)) | 66 self.assert_file_exists('%s%s' % (str(i), GYP_SUFFIX)) |
68 self.assert_file_exists('%s%s' % (str(i), OTHER_SUFFIX)) | 67 self.assert_file_exists('%s%s' % (str(i), OTHER_SUFFIX)) |
69 # Only the GYPD files should have been deleted. | 68 # Only the GYPD files should have been deleted. |
70 self.assert_file_does_not_exist('%s%s' % (str(i), GYPD_SUFFIX)) | 69 self.assert_file_does_not_exist('%s%s' % (str(i), GYPD_SUFFIX)) |
71 | 70 |
72 def tearDown(self): | 71 def tearDown(self): |
73 shutil.rmtree(self.__tmp_dir) | 72 shutil.rmtree(self.__tmp_dir) |
74 | 73 |
75 | 74 |
76 def main(): | 75 def main(): |
77 loader = unittest.TestLoader() | 76 loader = unittest.TestLoader() |
78 suite = loader.loadTestsFromTestCase(CleanGypdTest) | 77 suite = loader.loadTestsFromTestCase(CleanGypdTest) |
79 unittest.TextTestRunner(verbosity=2).run(suite) | 78 unittest.TextTestRunner(verbosity=2).run(suite) |
80 | 79 |
81 if __name__ == "__main__": | 80 if __name__ == "__main__": |
82 main() | 81 main() |
OLD | NEW |