summaryrefslogtreecommitdiffstats
path: root/PRESUBMIT_test.py
diff options
context:
space:
mode:
authoragrieve <agrieve@chromium.org>2016-03-24 13:06:40 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-24 20:08:06 +0000
commit9e299ea6bbf87415d64d9d84003162d71304ccb9 (patch)
tree5bf1ea48b3b6e70e99cd12bdea23a73358c4ac04 /PRESUBMIT_test.py
parentc38d1f4bce5165b0114fc9c429812e93f64850bf (diff)
downloadchromium_src-9e299ea6bbf87415d64d9d84003162d71304ccb9.zip
chromium_src-9e299ea6bbf87415d64d9d84003162d71304ccb9.tar.gz
chromium_src-9e299ea6bbf87415d64d9d84003162d71304ccb9.tar.bz2
Include isolate.py in data for Android unit tests
This is required for any test that uses an .isolate to push files to the device (e.g. base_unittests). BUG=589318 Review URL: https://codereview.chromium.org/1784373002 Cr-Commit-Position: refs/heads/master@{#383127}
Diffstat (limited to 'PRESUBMIT_test.py')
-rwxr-xr-xPRESUBMIT_test.py100
1 files changed, 96 insertions, 4 deletions
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py
index 90a8daf..c615c6b 100755
--- a/PRESUBMIT_test.py
+++ b/PRESUBMIT_test.py
@@ -3,12 +3,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import glob
-import json
-import os
import re
import subprocess
-import sys
import unittest
import PRESUBMIT
@@ -836,6 +832,102 @@ class UserMetricsActionTest(unittest.TestCase):
output[0].message)
+class PydepsNeedsUpdatingTest(unittest.TestCase):
+
+ class MockSubprocess(object):
+ CalledProcessError = subprocess.CalledProcessError
+
+ def setUp(self):
+ self.old_PYDEPS_FILES = PRESUBMIT._PYDEPS_FILES
+ PRESUBMIT._PYDEPS_FILES = ['A.pydeps', 'B.pydeps']
+ self.mock_input_api = MockInputApi()
+ self.mock_output_api = MockOutputApi()
+ self.mock_input_api.subprocess = PydepsNeedsUpdatingTest.MockSubprocess()
+ self.checker = PRESUBMIT.PydepsChecker(self.mock_input_api)
+ self.checker._file_cache = {
+ 'A.pydeps': '# target: //A.py\n# root: //\nA.py\nC.py\n',
+ 'B.pydeps': '# target: //B.py\n# root: //\nB.py\nC.py\n',
+ }
+
+ def tearDown(self):
+ PRESUBMIT._PYDEPS_FILES = self.old_PYDEPS_FILES
+
+ def _RunCheck(self):
+ return PRESUBMIT._CheckPydepsNeedsUpdating(self.mock_input_api,
+ self.mock_output_api,
+ checker_for_tests=self.checker)
+
+ def testAddedPydep(self):
+ self.mock_input_api.files = [
+ MockAffectedFile('new.pydeps', [], action='A'),
+ ]
+
+ results = self._RunCheck()
+ self.assertEqual(1, len(results))
+ self.assertTrue('PYDEPS_FILES' in str(results[0]))
+
+ def testRemovedPydep(self):
+ self.mock_input_api.files = [
+ MockAffectedFile(PRESUBMIT._PYDEPS_FILES[0], [], action='D'),
+ ]
+
+ results = self._RunCheck()
+ self.assertEqual(1, len(results))
+ self.assertTrue('PYDEPS_FILES' in str(results[0]))
+
+ def testRandomPyIgnored(self):
+ self.mock_input_api.files = [
+ MockAffectedFile('random.py', []),
+ ]
+
+ results = self._RunCheck()
+ self.assertEqual(0, len(results), 'Unexpected results: %r' % results)
+
+ def testRelevantPyNoChange(self):
+ self.mock_input_api.files = [
+ MockAffectedFile('A.py', []),
+ ]
+
+ def mock_check_output(cmd):
+ self.assertEqual('A.py', cmd[3])
+ return self.checker._file_cache['A.pydeps']
+
+ self.mock_input_api.subprocess.check_output = mock_check_output
+
+ results = self._RunCheck()
+ self.assertEqual(0, len(results), 'Unexpected results: %r' % results)
+
+ def testRelevantPyOneChange(self):
+ self.mock_input_api.files = [
+ MockAffectedFile('A.py', []),
+ ]
+
+ def mock_check_output(cmd):
+ self.assertEqual('A.py', cmd[3])
+ return 'changed data'
+
+ self.mock_input_api.subprocess.check_output = mock_check_output
+
+ results = self._RunCheck()
+ self.assertEqual(1, len(results))
+ self.assertTrue('File is stale' in str(results[0]))
+
+ def testRelevantPyTwoChanges(self):
+ self.mock_input_api.files = [
+ MockAffectedFile('C.py', []),
+ ]
+
+ def mock_check_output(cmd):
+ return 'changed data'
+
+ self.mock_input_api.subprocess.check_output = mock_check_output
+
+ results = self._RunCheck()
+ self.assertEqual(2, len(results))
+ self.assertTrue('File is stale' in str(results[0]))
+ self.assertTrue('File is stale' in str(results[1]))
+
+
class LogUsageTest(unittest.TestCase):
def testCheckAndroidCrLogUsage(self):