OLD | NEW |
---|---|
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """This script tests the installer with test cases specified in the config file. | 5 """This script tests the installer with test cases specified in the config file. |
6 | 6 |
7 For each test case, it checks that the machine states after the execution of | 7 For each test case, it checks that the machine states after the execution of |
8 each command match the expected machine states. For more details, take a look at | 8 each command match the expected machine states. For more details, take a look at |
9 the design documentation at http://goo.gl/Q0rGM6 | 9 the design documentation at http://goo.gl/Q0rGM6 |
10 """ | 10 """ |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 Args: | 98 Args: |
99 state: A state name. | 99 state: A state name. |
100 """ | 100 """ |
101 try: | 101 try: |
102 verifier.Verify(self._config.states[state], self._path_resolver) | 102 verifier.Verify(self._config.states[state], self._path_resolver) |
103 except AssertionError as e: | 103 except AssertionError as e: |
104 # If an AssertionError occurs, we intercept it and add the state name | 104 # If an AssertionError occurs, we intercept it and add the state name |
105 # to the error message so that we know where the test fails. | 105 # to the error message so that we know where the test fails. |
106 raise AssertionError("In state '%s', %s" % (state, e)) | 106 raise AssertionError("In state '%s', %s" % (state, e)) |
107 | 107 |
108 def _RunCommand(self, command): | 108 def _RunCommand(self, command): |
robertshield
2013/09/04 22:16:29
please add a brief method comment that mentions th
sukolsak
2013/09/04 22:53:49
Done.
| |
109 exit_status = subprocess.call(self._path_resolver.ResolvePath(command), | 109 resolved_command = self._path_resolver.ResolvePath(command) |
110 shell=True) | 110 script_dir = os.path.dirname(__file__) |
111 exit_status = subprocess.call(resolved_command, shell=True, cwd=script_dir) | |
111 if exit_status != 0: | 112 if exit_status != 0: |
112 self.fail('Command %s returned non-zero exit status %s' % (command, | 113 self.fail('Command %s returned non-zero exit status %s' % ( |
113 exit_status)) | 114 resolved_command, exit_status)) |
114 | 115 |
115 | 116 |
116 def MergePropertyDictionaries(current_property, new_property): | 117 def MergePropertyDictionaries(current_property, new_property): |
117 """Merges the new property dictionary into the current property dictionary. | 118 """Merges the new property dictionary into the current property dictionary. |
118 | 119 |
119 This is different from general dictionary merging in that, in case there are | 120 This is different from general dictionary merging in that, in case there are |
120 keys with the same name, we merge values together in the first level, and we | 121 keys with the same name, we merge values together in the first level, and we |
121 override earlier values in the second level. For more details, take a look at | 122 override earlier values in the second level. For more details, take a look at |
122 http://goo.gl/uE0RoR | 123 http://goo.gl/uE0RoR |
123 | 124 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 assert os.path.exists(mini_installer_path), ('Could not find file %s' % | 216 assert os.path.exists(mini_installer_path), ('Could not find file %s' % |
216 mini_installer_path) | 217 mini_installer_path) |
217 config = ParseConfigFile(config_filename) | 218 config = ParseConfigFile(config_filename) |
218 if not RunTests(mini_installer_path, config): | 219 if not RunTests(mini_installer_path, config): |
219 return 1 | 220 return 1 |
220 return 0 | 221 return 0 |
221 | 222 |
222 | 223 |
223 if __name__ == '__main__': | 224 if __name__ == '__main__': |
224 sys.exit(main()) | 225 sys.exit(main()) |
OLD | NEW |