Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Unified Diff: tools/isolate/isolate_test.py

Issue 9513003: Add target base_unittests_run and tools/isolate/isolate.py. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove directory from 'inputs' Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/isolate/isolate.py ('k') | tools/isolate/pylintrc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/isolate/isolate_test.py
diff --git a/tools/isolate/isolate_test.py b/tools/isolate/isolate_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..eb44d5341fdd1748899e36d15868aae437fade5c
--- /dev/null
+++ b/tools/isolate/isolate_test.py
@@ -0,0 +1,91 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import shutil
+import subprocess
+import sys
+import tempfile
+import unittest
+
+ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
+
+
+class Isolate(unittest.TestCase):
+ def setUp(self):
+ self.tempdir = tempfile.mkdtemp()
+ self.result = os.path.join(self.tempdir, 'result')
+
+ def tearDown(self):
+ shutil.rmtree(self.tempdir)
+
+ def _execute(self, args):
+ cmd = [
+ sys.executable, os.path.join(ROOT_DIR, 'isolate.py'),
+ '--root', ROOT_DIR,
+ '--result', self.result,
+ ]
+ subprocess.check_call(
+ cmd + args,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+
+ def test_check(self):
+ cmd = [
+ '--mode', 'check',
+ 'isolate_test.py',
+ ]
+ self._execute(cmd)
+ self.assertTrue(os.path.isfile(self.result))
+
+ def test_check_non_existant(self):
+ cmd = [
+ '--mode', 'check',
+ 'NonExistentFile',
+ ]
+ try:
+ self._execute(cmd)
+ self.fail()
+ except subprocess.CalledProcessError:
+ pass
+ self.assertFalse(os.path.isfile(self.result))
+
+ def test_run(self):
+ cmd = [
+ '--mode', 'run',
+ 'isolate_test.py',
+ '--',
+ sys.executable, 'isolate_test.py', '--ok',
+ ]
+ self._execute(cmd)
+ self.assertTrue(os.path.isfile(self.result))
+
+ def test_run_fail(self):
+ cmd = [
+ '--mode', 'run',
+ 'isolate_test.py',
+ '--',
+ sys.executable, 'isolate_test.py', '--fail',
+ ]
+ try:
+ self._execute(cmd)
+ self.fail()
+ except subprocess.CalledProcessError:
+ pass
+ self.assertFalse(os.path.isfile(self.result))
+
+
+def main():
+ if len(sys.argv) == 1:
+ unittest.main()
+ if sys.argv[1] == '--ok':
+ return 0
+ if sys.argv[1] == '--fail':
+ return 1
+ unittest.main()
+
+
+if __name__ == '__main__':
+ sys.exit(main())
« no previous file with comments | « tools/isolate/isolate.py ('k') | tools/isolate/pylintrc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698