34 class TestInfo(BaseTestCase): |
34 class TestInfo(BaseTestCase): |
35 |
35 |
36 def test_get_help(self): |
36 def test_get_help(self): |
37 cmd = '%s -h' % get_cmd('info') |
37 cmd = '%s -h' % get_cmd('info') |
38 out = self.run_command(cmd) |
38 out = self.run_command(cmd) |
39 lines = out.split('\r\n') |
39 lines = out.split(os.linesep) |
40 self.assertTrue('Options:' in lines) |
40 self.assertTrue('Options:' in lines) |
41 self.assertTrue(' Info options:' in lines) |
41 self.assertTrue(' Info options:' in lines) |
42 |
42 |
43 |
43 |
44 def test_get_project_info(self): |
44 def test_get_project_info(self): |
45 self.set_modification_reference_time(testproject) |
45 self.set_modification_reference_time(testproject) |
46 cmd = '%s -p "%s"' % (get_cmd('info'), testproject) |
46 cmd = '%s -p "%s"' % (get_cmd('info'), testproject) |
47 out = self.run_command(cmd) |
47 out = self.run_command(cmd) |
48 |
48 |
49 lines = out.split('\r\n') |
49 lines = out.split(os.linesep) |
50 self.assertTrue('Configurations in the project.' in lines) |
50 self.assertTrue('Configurations in the project.' in lines) |
51 self.assertTrue('root1.confml' in lines) |
51 self.assertTrue('root1.confml' in lines) |
52 self.assertTrue('root2.confml' in lines) |
52 self.assertTrue('root2.confml' in lines) |
53 self.assertTrue('root3.confml' in lines) |
53 self.assertTrue('root3.confml' in lines) |
54 self.assertTrue('root4.confml' in lines) |
54 self.assertTrue('root4.confml' in lines) |
55 self.assertTrue('root5.confml' in lines) |
55 self.assertTrue('root5.confml' in lines) |
56 |
56 |
57 self.assert_not_modified(testproject) |
57 self.assert_not_modified(testproject) |
|
58 |
|
59 def test_print_active_root(self): |
|
60 cmd = '%s -p "%s" --print-active-root' % (get_cmd('info'), testproject) |
|
61 out = self.run_command(cmd) |
|
62 self.assertTrue('Active root: root5.confml' in out) |
|
63 |
|
64 project = os.path.join(ROOT_PATH,'test_variant.cpf') |
|
65 cmd = '%s -p "%s" --print-active-root' % (get_cmd('info'), project) |
|
66 out = self.run_command(cmd) |
|
67 self.assertTrue('Active root: root.confml' in out) |
|
68 |
|
69 project = os.path.join(ROOT_PATH, 'testdata/info/no_active_root.cpf') |
|
70 cmd = '%s -p "%s" --print-active-root' % (get_cmd('info'), project) |
|
71 out = self.run_command(cmd) |
|
72 self.assertTrue('No active root.' in out) |
|
73 |
58 |
74 |
59 def test_api_report(self): |
75 def test_api_report(self): |
60 EXPECTED_FILE = os.path.join(ROOT_PATH, 'testdata/info/expected/api_report.html') |
76 EXPECTED_FILE = os.path.join(ROOT_PATH, 'testdata/info/expected/api_report.html') |
61 REPORT_FILE = os.path.join(temp_dir, 'api_report.html') |
77 REPORT_FILE = os.path.join(temp_dir, 'api_report.html') |
62 self.remove_if_exists(REPORT_FILE) |
78 self.remove_if_exists(REPORT_FILE) |
161 |
177 |
162 def test_value_report_configs_with_regex(self): |
178 def test_value_report_configs_with_regex(self): |
163 self._run_test_value_report( |
179 self._run_test_value_report( |
164 output = 'value_report_langpacks_regex.html', |
180 output = 'value_report_langpacks_regex.html', |
165 expected = 'value_report_langpacks.html', |
181 expected = 'value_report_langpacks.html', |
166 args = '--config-regex product_langpack_\\d{2}_root.confml') |
182 args = '--config-regex product_langpack_[0-9]{2}_root.confml') |
167 |
183 |
168 def test_value_report_multi_config(self): |
184 def test_value_report_multi_config(self): |
169 self._run_test_value_report( |
185 self._run_test_value_report( |
170 output = 'value_report_langpacks_regex.html', |
186 output = 'value_report_langpacks_regex.html', |
171 expected = 'value_report_langpacks.html', |
187 expected = 'value_report_langpacks.html', |
216 def test_value_report_custom_template(self): |
232 def test_value_report_custom_template(self): |
217 TEMPLATE_FILE = os.path.join(ROOT_PATH, 'testdata/info/custom_value_report_template.html') |
233 TEMPLATE_FILE = os.path.join(ROOT_PATH, 'testdata/info/custom_value_report_template.html') |
218 EXPECTED_FILE = os.path.join(ROOT_PATH, 'testdata/info/expected/value_report_custom.html') |
234 EXPECTED_FILE = os.path.join(ROOT_PATH, 'testdata/info/expected/value_report_custom.html') |
219 REPORT_FILE = os.path.join(temp_dir, 'value_report_custom.html') |
235 REPORT_FILE = os.path.join(temp_dir, 'value_report_custom.html') |
220 self.remove_if_exists(REPORT_FILE) |
236 self.remove_if_exists(REPORT_FILE) |
221 cmd = '%s -p "%s" --template "%s" --report "%s" -c product_root.confml' \ |
237 cmd = '%s -p "%s" --template "%s" --log-file="%s" --report "%s" -c product_root.confml' \ |
222 % (get_cmd('info'), VALUE_REPORT_PROJECT, TEMPLATE_FILE, REPORT_FILE) |
238 % (get_cmd('info'), VALUE_REPORT_PROJECT, |
|
239 TEMPLATE_FILE, |
|
240 os.path.join(temp_dir, 'value_report_custom_cone.log'), |
|
241 REPORT_FILE) |
223 out = self.run_command(cmd) |
242 out = self.run_command(cmd) |
224 |
243 |
225 self.assert_file_contents_equal(EXPECTED_FILE, REPORT_FILE) |
244 self.assert_file_contents_equal(EXPECTED_FILE, REPORT_FILE) |
226 |
245 |
227 if __name__ == '__main__': |
246 if __name__ == '__main__': |