From dbd6476c4e630266e47e5c3e904c770272c7a307 Mon Sep 17 00:00:00 2001 From: Edward Lesmes Date: Thu, 5 Apr 2018 18:21:09 -0400 Subject: [PATCH] presubmit_unittest: Remove redundant tests. Bug: 829134 Change-Id: I3a29b67d96e04162425148a401dfb384efd5cef3 Reviewed-on: https://chromium-review.googlesource.com/998629 Commit-Queue: Edward Lesmes Reviewed-by: Aaron Gable --- tests/gclient_smoketest.py | 17 --------- tests/presubmit_unittest.py | 76 +++---------------------------------- 2 files changed, 6 insertions(+), 87 deletions(-) diff --git a/tests/gclient_smoketest.py b/tests/gclient_smoketest.py index e83627790..5927b243a 100755 --- a/tests/gclient_smoketest.py +++ b/tests/gclient_smoketest.py @@ -155,23 +155,6 @@ class GClientSmoke(GClientSmokeBase): def git_base(self): return 'git://random.server/git/' - def testHelp(self): - """testHelp: make sure no new command was added.""" - result = self.gclient(['help']) - # Roughly, not too short, not too long. - self.assertTrue(1000 < len(result[0]) and len(result[0]) < 2300, - 'Too much written to stdout: %d bytes' % len(result[0])) - self.assertEquals(0, len(result[1])) - self.assertEquals(0, result[2]) - - def testUnknown(self): - result = self.gclient(['foo']) - # Roughly, not too short, not too long. - self.assertTrue(1000 < len(result[0]) and len(result[0]) < 2300, - 'Too much written to stdout: %d bytes' % len(result[0])) - self.assertEquals(0, len(result[1])) - self.assertEquals(0, result[2]) - def testNotConfigured(self): res = ('', 'Error: client not configured; see \'gclient config\'\n', 1) self.check(res, self.gclient(['diff'])) diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py index 02bb10418..ed88437c6 100755 --- a/tests/presubmit_unittest.py +++ b/tests/presubmit_unittest.py @@ -764,66 +764,6 @@ def CheckChangeOnCommit(input_api, output_api): 'on the file to figure out who to ask for help.\n') self.assertEquals(output.getvalue(), text) - def testDoPresubmitChecksWithTags(self): - tag_checker_presubmit_script = """ -def CheckChangeOnUpload(input_api, output_api): - if input_api.change.tags['BUG'] != 'boo': - return [output_api.PresubmitError('Tag parsing failed. 1')] - if input_api.change.tags['STORY'] != 'http://tracker.com/42': - return [output_api.PresubmitError('Tag parsing failed. 2')] - try: - y = False - x = input_api.change.invalid - except AttributeError: - y = True - if not y: - return [output_api.PresubmitError('Tag parsing failed. 8')] - if 'TEST' in input_api.change.tags: - return [output_api.PresubmitError('Tag parsing failed. 3')] - if input_api.change.DescriptionText() != 'Blah Blah': - return [output_api.PresubmitError('Tag parsing failed. 4 ' + - input_api.change.DescriptionText())] - if (input_api.change.FullDescriptionText() != - 'Blah Blah\\n\\nSTORY=http://tracker.com/42\\nBUG=boo\\n'): - return [output_api.PresubmitError('Tag parsing failed. 5 ' + - input_api.change.FullDescriptionText())] - return [output_api.PresubmitNotifyResult(input_api.change.tags['STORY'])] -def CheckChangeOnCommit(input_api, output_api): - raise Exception("Test error") -""" - presubmit.random.randint(0, 4).AndReturn(1) - inherit_path = presubmit.os.path.join( - self.fake_root_dir, self._INHERIT_SETTINGS) - presubmit.os.path.isfile(inherit_path).AndReturn(False) - self.mox.ReplayAll() - - output_buf = StringIO.StringIO() - input_buf = StringIO.StringIO('y\n') - change = presubmit.Change( - 'foo', - 'Blah Blah\n\nSTORY=http://tracker.com/42\nBUG=boo\n', - self.fake_root_dir, - None, - 0, - 0, - None) - presubmit_output = presubmit.DoPresubmitChecks( - change=change, committing=False, verbose=True, - output_stream=output_buf, input_stream=input_buf, - default_presubmit=tag_checker_presubmit_script, - may_prompt=False, gerrit_obj=None) - - self.failUnless(presubmit_output) - self.assertEquals(output_buf.getvalue(), - ('Running presubmit upload checks ...\n' - 'Warning, no PRESUBMIT.py found.\n' - 'Running default presubmit script.\n' - '\n' - '** Presubmit Messages **\n' - 'http://tracker.com/42\n' - '\n' - 'Presubmit checks passed.\n')) - def testGetTryMastersExecuter(self): self.mox.ReplayAll() change = self.ExampleChange( @@ -1664,15 +1604,9 @@ class ChangeUnittest(PresubmitTestsBase): 'foo', 'foo', self.fake_root_dir, [('M', 'AA')], 0, 0, 'foo') self.compareMembers(change, members) - def testMembers(self): + def testAffectedFiles(self): change = presubmit.Change( - 'foo1', 'foo2\nDRU=ro', self.fake_root_dir, [('Y', 'AA')], 3, 5, 'foo3') - self.assertEquals('foo1', change.Name()) - self.assertEquals('foo2', change.DescriptionText()) - self.assertEquals('foo3', change.author_email) - self.assertEquals(3, change.issue) - self.assertEquals(5, change.patchset) - self.assertEquals(self.fake_root_dir, change.RepositoryRoot()) + '', '', self.fake_root_dir, [('Y', 'AA')], 3, 5, '') self.assertEquals(1, len(change.AffectedFiles())) self.assertEquals('Y', change.AffectedFiles()[0].Action()) @@ -1681,10 +1615,12 @@ class ChangeUnittest(PresubmitTestsBase): '', 'foo\nDRU=ro', self.fake_root_dir, [], 3, 5, '') self.assertEquals('foo', change.DescriptionText()) self.assertEquals('foo\nDRU=ro', change.FullDescriptionText()) + self.assertEquals({'DRU': 'ro'}, change.tags) - change.SetDescriptionText('bar\nWHIZ=bang') + change.SetDescriptionText('WHIZ=bang\nbar\nFOO=baz') self.assertEquals('bar', change.DescriptionText()) - self.assertEquals('bar\nWHIZ=bang', change.FullDescriptionText()) + self.assertEquals('WHIZ=bang\nbar\nFOO=baz', change.FullDescriptionText()) + self.assertEquals({'WHIZ': 'bang', 'FOO': 'baz'}, change.tags) def testBugsFromDescription(self): change = presubmit.Change(