Skip to content

Commit 31ca877

Browse files
randomasciiLUCI CQ
authored and
LUCI CQ
committed
Fix CheckLicense tests
A last minute change to the CheckLicense tests in crrev.com/c/4032366 used the _GetLicenseText function in the wrong place, thus neutering one test and duplicating code in another. This fixes the tests so that they minimize duplication and actually test the CSS/C style comments. Change-Id: Ibbe880dec8d1e85416ed1b7ce94922c6f2c2a543 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4037103 Commit-Queue: Bruce Dawson <[email protected]> Reviewed-by: Josip Sokcevic <[email protected]>
1 parent 1f67d55 commit 31ca877

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

tests/presubmit_unittest.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -2354,14 +2354,7 @@ def testCheckLicenseEmptySuccess(self):
23542354
self._LicenseCheck(text, license_text, True, None, accept_empty_files=True)
23552355

23562356
def testCheckLicenseNewFilePass(self):
2357-
current_year = int(time.strftime('%Y'))
2358-
text = (
2359-
"#!/bin/python\n"
2360-
"# Copyright %d The Chromium Authors\n"
2361-
"# Use of this source code is governed by a BSD-style license that can "
2362-
"be\n"
2363-
"# found in the LICENSE file.\n"
2364-
"print('foo')\n" % current_year)
2357+
text = self._GetLicenseText(int(time.strftime('%Y')))
23652358
license_text = None
23662359
self._LicenseCheck(text, license_text, False, None, new_file=True)
23672360

@@ -2403,7 +2396,15 @@ def testCheckLicenseNewFileWarn(self):
24032396
new_file=True)
24042397

24052398
def testCheckLicenseNewCSSFilePass(self):
2406-
text = self._GetLicenseText(int(time.strftime('%Y')))
2399+
# Check that CSS-style comments in license text are supported.
2400+
current_year = int(time.strftime('%Y'))
2401+
text = (
2402+
"/* Copyright %d The Chromium Authors\n"
2403+
" * Use of this source code is governed by a BSD-style license that "
2404+
"can be\n"
2405+
"* found in the LICENSE file. */\n"
2406+
"\n"
2407+
"h1 {}\n" % current_year)
24072408
license_text = None
24082409
self._LicenseCheck(text, license_text, False, None, new_file=True)
24092410

0 commit comments

Comments
 (0)