| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import logging | 6 import logging |
| 7 import os | 7 import os |
| 8 import subprocess | 8 import subprocess |
| 9 import sys | 9 import sys |
| 10 import unittest | 10 import unittest |
| 11 | 11 |
| 12 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | 12 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 13 | 13 |
| 14 ISOLATE_SERVER = 'https://isolateserver.appspot.com/' |
| 15 SWARMING_SERVER = 'https://chromium-swarm.appspot.com/' |
| 16 |
| 14 | 17 |
| 15 class TestSwarm(unittest.TestCase): | 18 class TestSwarm(unittest.TestCase): |
| 16 def test_example(self): | 19 def test_example(self): |
| 17 # pylint: disable=W0101 | 20 # pylint: disable=W0101 |
| 18 # A user should be able to trigger a swarm job and return results. | 21 # A user should be able to trigger a swarm job and return results. |
| 19 cmd = [ | 22 cmd = [ |
| 20 sys.executable, | 23 sys.executable, |
| 21 os.path.normpath( | 24 os.path.normpath( |
| 22 os.path.join(BASE_DIR, '..', 'example', 'run_example_swarm.py')), | 25 os.path.join(BASE_DIR, '..', 'example', 'run_example_swarm.py')), |
| 26 '--isolate-server', ISOLATE_SERVER, |
| 27 '--swarming', SWARMING_SERVER, |
| 23 ] | 28 ] |
| 29 if '-v' in sys.argv: |
| 30 cmd.append('--verbose') |
| 24 p = subprocess.Popen( | 31 p = subprocess.Popen( |
| 25 cmd, | 32 cmd, |
| 26 stdin=subprocess.PIPE, | 33 stdin=subprocess.PIPE, |
| 27 stdout=subprocess.PIPE, | 34 stdout=subprocess.PIPE, |
| 28 stderr=subprocess.STDOUT) | 35 stderr=subprocess.STDOUT) |
| 29 out = p.communicate()[0] | 36 out = p.communicate()[0] |
| 30 logging.debug(out) | 37 logging.debug(out) |
| 31 self.assertEqual(0, p.returncode, out) | 38 self.assertEqual(0, p.returncode, out) |
| 32 | 39 |
| 33 | 40 |
| 34 if __name__ == '__main__': | 41 if __name__ == '__main__': |
| 35 logging.basicConfig( | 42 logging.basicConfig( |
| 36 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR) | 43 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR) |
| 37 if '-v' in sys.argv: | 44 if '-v' in sys.argv: |
| 38 unittest.TestCase.maxDiff = None | 45 unittest.TestCase.maxDiff = None |
| 39 unittest.main() | 46 unittest.main() |
| OLD | NEW |