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

Unified Diff: tests/fix_test_cases_smoke_test.py

Issue 19917006: Move all googletest related scripts into googletest/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/swarm_client
Patch Set: Remove unnecessary pylint warning disable Created 7 years, 5 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 | « shard_test_cases.py ('k') | tests/gtest_fake/__init__.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/fix_test_cases_smoke_test.py
diff --git a/tests/fix_test_cases_smoke_test.py b/tests/fix_test_cases_smoke_test.py
deleted file mode 100755
index 3f501491c1dbd89a31a5e6e2932e5cd2d37b67ef..0000000000000000000000000000000000000000
--- a/tests/fix_test_cases_smoke_test.py
+++ /dev/null
@@ -1,168 +0,0 @@
-#!/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 hashlib
-import json
-import logging
-import os
-import shutil
-import subprocess
-import sys
-import tempfile
-import unittest
-
-BASE_DIR = os.path.dirname(os.path.abspath(__file__))
-ROOT_DIR = os.path.dirname(BASE_DIR)
-sys.path.insert(0, ROOT_DIR)
-
-import run_isolated
-
-
-class FixTestCases(unittest.TestCase):
- def setUp(self):
- self.tempdir = tempfile.mkdtemp(prefix='fix_test_case')
- self.srcdir = os.path.join(self.tempdir, 'srcdir')
- os.mkdir(self.srcdir)
-
- def tearDown(self):
- if self.tempdir:
- if VERBOSE:
- # If -v is used, this means the user wants to do further analisys on
- # the data.
- print('Leaking %s' % self.tempdir)
- else:
- shutil.rmtree(self.tempdir)
-
- def _run(self, cmd):
- if VERBOSE:
- cmd = cmd + ['--verbose'] * 3
- logging.info(cmd)
- proc = subprocess.Popen(
- [sys.executable, os.path.join(ROOT_DIR, cmd[0])] + cmd[1:],
- cwd=self.srcdir,
- stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT)
- out = proc.communicate()[0]
- if VERBOSE:
- print '\n-----'
- print out.strip()
- print '-----\n'
- self.assertEqual(0, proc.returncode)
- return out
-
- def test_simple(self):
- # Create a directory with nothing in it and progressively add more stuff.
- isolate = os.path.join(self.srcdir, 'gtest_fake_pass.isolate')
- chromeos_value = int(run_isolated.get_flavor() == 'linux')
- condition = 'OS=="%s" and chromeos==%d' % (run_isolated.get_flavor(),
- chromeos_value)
- with open(isolate, 'w') as f:
- # Write a minimal .isolate file.
- f.write(str({
- 'conditions': [
- [condition, {
- 'variables': {
- 'command': [
- 'run_test_cases.py', 'gtest_fake_pass.py',
- ],
- },
- }],
- ],
- }))
- def _copy(filename):
- shutil.copy(
- os.path.join(BASE_DIR, 'gtest_fake', filename),
- os.path.join(self.srcdir, filename))
- _copy('gtest_fake_base.py')
- _copy('gtest_fake_pass.py')
- shutil.copy(
- os.path.join(ROOT_DIR, 'run_test_cases.py'),
- os.path.join(self.srcdir, 'run_test_cases.py'))
- shutil.copy(
- os.path.join(ROOT_DIR, 'run_isolated.py'),
- os.path.join(self.srcdir, 'run_isolated.py'))
-
- logging.debug('1. Create a .isolated file out of the .isolate file.')
- isolated = os.path.join(self.srcdir, 'gtest_fake_pass.isolated')
- out = self._run(['isolate.py', 'check', '-i', isolate, '-s', isolated,
- '-V', 'chromeos', str(chromeos_value)])
- if not VERBOSE:
- self.assertEqual('', out)
-
- logging.debug('2. Run fix_test_cases.py on it.')
- # Give up on looking at stdout.
- _ = self._run(['fix_test_cases.py', '-s', isolated])
-
- logging.debug('3. Asserting the content of the .isolated file.')
- with open(isolated) as f:
- actual_isolated = json.load(f)
- gtest_fake_base_py = os.path.join(self.srcdir, 'gtest_fake_base.py')
- gtest_fake_pass_py = os.path.join(self.srcdir, 'gtest_fake_pass.py')
- run_isolated_py = os.path.join(self.srcdir, 'run_isolated.py')
- run_test_cases_py = os.path.join(self.srcdir, 'run_test_cases.py')
- expected_isolated = {
- u'command': [u'run_test_cases.py', u'gtest_fake_pass.py'],
- u'files': {
- u'gtest_fake_base.py': {
- u'm': 416,
- u'h': unicode(hashlib.sha1(
- open(gtest_fake_base_py, 'rb').read()).hexdigest()),
- u's': os.stat(gtest_fake_base_py).st_size,
- },
- u'gtest_fake_pass.py': {
- u'm': 488,
- u'h': unicode(hashlib.sha1(
- open(gtest_fake_pass_py, 'rb').read()).hexdigest()),
- u's': os.stat(gtest_fake_pass_py).st_size,
- },
- u'run_isolated.py': {
- u'm': 488,
- u'h': unicode(hashlib.sha1(
- open(run_isolated_py, 'rb').read()).hexdigest()),
- u's': os.stat(run_isolated_py).st_size,
- },
- u'run_test_cases.py': {
- u'm': 488,
- u'h': unicode(hashlib.sha1(
- open(run_test_cases_py, 'rb').read()).hexdigest()),
- u's': os.stat(run_test_cases_py).st_size,
- },
- },
- u'os': unicode(run_isolated.get_flavor()),
- u'relative_cwd': u'.',
- }
- if sys.platform == 'win32':
- for value in expected_isolated['files'].itervalues():
- self.assertTrue(value.pop('m'))
- self.assertEqual(expected_isolated, actual_isolated)
-
- # Now verify the .isolate file was updated! (That's the magical part where
- # you say wow!)
- with open(isolate) as f:
- actual = eval(f.read(), {'__builtins__': None}, None)
- expected = {
- 'conditions': [
- [condition, {
- 'variables': {
- 'command': [
- 'run_test_cases.py', 'gtest_fake_pass.py'
- ],
- 'isolate_dependency_tracked': [
- 'gtest_fake_base.py',
- 'gtest_fake_pass.py',
- 'run_isolated.py',
- 'run_test_cases.py',
- ],
- },
- }],
- ],
- }
- self.assertEqual(expected, actual)
-
-
-if __name__ == '__main__':
- VERBOSE = '-v' in sys.argv
- logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR)
- unittest.main()
« no previous file with comments | « shard_test_cases.py ('k') | tests/gtest_fake/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698