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 <brucedawson@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
changes/03/4037103/2
Bruce Dawson 3 years ago committed by LUCI CQ
parent 1f67d5573f
commit 31ca877242

@ -2354,14 +2354,7 @@ the current line as well!
self._LicenseCheck(text, license_text, True, None, accept_empty_files=True)
def testCheckLicenseNewFilePass(self):
current_year = int(time.strftime('%Y'))
text = (
"#!/bin/python\n"
"# Copyright %d The Chromium Authors\n"
"# Use of this source code is governed by a BSD-style license that can "
"be\n"
"# found in the LICENSE file.\n"
"print('foo')\n" % current_year)
text = self._GetLicenseText(int(time.strftime('%Y')))
license_text = None
self._LicenseCheck(text, license_text, False, None, new_file=True)
@ -2403,7 +2396,15 @@ the current line as well!
new_file=True)
def testCheckLicenseNewCSSFilePass(self):
text = self._GetLicenseText(int(time.strftime('%Y')))
# Check that CSS-style comments in license text are supported.
current_year = int(time.strftime('%Y'))
text = (
"/* Copyright %d The Chromium Authors\n"
" * Use of this source code is governed by a BSD-style license that "
"can be\n"
"* found in the LICENSE file. */\n"
"\n"
"h1 {}\n" % current_year)
license_text = None
self._LicenseCheck(text, license_text, False, None, new_file=True)

Loading…
Cancel
Save