mirror of
https://github.com/flutter/packages.git
synced 2025-06-04 02:08:40 +08:00
Fix cosmetic variations in copyrights and license files (#3730)
- Replaces "the Flutter project authors" with the repo-standard version "The Flutter Authors" - Updates the license check not to allow "the Flutter project authors" in the future - Fixes a few minor cosmetic variations that had crept back into LICENSE files since my mass-standardization of those files. - Updates the license check to validate those to prevent such drift in the future.
This commit is contained in:
@ -134,7 +134,7 @@ void main() {
|
||||
|
||||
// Sanity check that the test did actually check a file.
|
||||
expect(printedMessages, contains('Checking checked.cc'));
|
||||
expect(printedMessages, contains('All files passed validation!'));
|
||||
expect(printedMessages, contains('All source files passed validation!'));
|
||||
});
|
||||
|
||||
test('handles the comment styles for all supported languages', () async {
|
||||
@ -154,7 +154,7 @@ void main() {
|
||||
expect(printedMessages, contains('Checking file_a.cc'));
|
||||
expect(printedMessages, contains('Checking file_b.sh'));
|
||||
expect(printedMessages, contains('Checking file_c.html'));
|
||||
expect(printedMessages, contains('All files passed validation!'));
|
||||
expect(printedMessages, contains('All source files passed validation!'));
|
||||
});
|
||||
|
||||
test('fails if any checked files are missing license blocks', () async {
|
||||
@ -176,7 +176,8 @@ void main() {
|
||||
expect(printedMessages, contains(' bad.cc'));
|
||||
expect(printedMessages, contains(' bad.h'));
|
||||
// Failure shouldn't print the success message.
|
||||
expect(printedMessages, isNot(contains('All files passed validation!')));
|
||||
expect(printedMessages,
|
||||
isNot(contains('All source files passed validation!')));
|
||||
});
|
||||
|
||||
test('fails if any checked files are missing just the copyright', () async {
|
||||
@ -195,7 +196,8 @@ void main() {
|
||||
contains('No copyright line was found for the following files:'));
|
||||
expect(printedMessages, contains(' bad.cc'));
|
||||
// Failure shouldn't print the success message.
|
||||
expect(printedMessages, isNot(contains('All files passed validation!')));
|
||||
expect(printedMessages,
|
||||
isNot(contains('All source files passed validation!')));
|
||||
});
|
||||
|
||||
test('fails if any checked files are missing just the license', () async {
|
||||
@ -214,7 +216,8 @@ void main() {
|
||||
contains('No recognized license was found for the following files:'));
|
||||
expect(printedMessages, contains(' bad.cc'));
|
||||
// Failure shouldn't print the success message.
|
||||
expect(printedMessages, isNot(contains('All files passed validation!')));
|
||||
expect(printedMessages,
|
||||
isNot(contains('All source files passed validation!')));
|
||||
});
|
||||
|
||||
test('fails if any third-party code is not in a third_party directory',
|
||||
@ -234,7 +237,8 @@ void main() {
|
||||
'but are not in a "third_party/" directory:'));
|
||||
expect(printedMessages, contains(' third_party.cc'));
|
||||
// Failure shouldn't print the success message.
|
||||
expect(printedMessages, isNot(contains('All files passed validation!')));
|
||||
expect(printedMessages,
|
||||
isNot(contains('All source files passed validation!')));
|
||||
});
|
||||
|
||||
test('succeeds for third-party code in a third_party directory', () async {
|
||||
@ -252,7 +256,7 @@ void main() {
|
||||
// Sanity check that the test did actually check the file.
|
||||
expect(printedMessages,
|
||||
contains('Checking a_plugin/lib/src/third_party/file.cc'));
|
||||
expect(printedMessages, contains('All files passed validation!'));
|
||||
expect(printedMessages, contains('All source files passed validation!'));
|
||||
});
|
||||
|
||||
test('fails for licenses that the tool does not expect', () async {
|
||||
@ -274,7 +278,8 @@ void main() {
|
||||
contains('No recognized license was found for the following files:'));
|
||||
expect(printedMessages, contains(' third_party/bad.cc'));
|
||||
// Failure shouldn't print the success message.
|
||||
expect(printedMessages, isNot(contains('All files passed validation!')));
|
||||
expect(printedMessages,
|
||||
isNot(contains('All source files passed validation!')));
|
||||
});
|
||||
|
||||
test('Apache is not recognized for new authors without validation changes',
|
||||
@ -300,7 +305,107 @@ void main() {
|
||||
contains('No recognized license was found for the following files:'));
|
||||
expect(printedMessages, contains(' third_party/bad.cc'));
|
||||
// Failure shouldn't print the success message.
|
||||
expect(printedMessages, isNot(contains('All files passed validation!')));
|
||||
expect(printedMessages,
|
||||
isNot(contains('All source files passed validation!')));
|
||||
});
|
||||
|
||||
test('passes if all first-party LICENSE files are correctly formatted',
|
||||
() async {
|
||||
File license = root.childFile('LICENSE');
|
||||
license.createSync();
|
||||
license.writeAsStringSync(_correctLicenseFileText);
|
||||
|
||||
await runner.run(<String>['license-check']);
|
||||
|
||||
// Sanity check that the test did actually check the file.
|
||||
expect(printedMessages, contains('Checking LICENSE'));
|
||||
expect(printedMessages, contains('All LICENSE files passed validation!'));
|
||||
});
|
||||
|
||||
test('fails if any first-party LICENSE files are incorrectly formatted',
|
||||
() async {
|
||||
File license = root.childFile('LICENSE');
|
||||
license.createSync();
|
||||
license.writeAsStringSync(_incorrectLicenseFileText);
|
||||
|
||||
await expectLater(() => runner.run(<String>['license-check']),
|
||||
throwsA(const TypeMatcher<ToolExit>()));
|
||||
|
||||
expect(printedMessages,
|
||||
isNot(contains('All LICENSE files passed validation!')));
|
||||
});
|
||||
|
||||
test('ignores third-party LICENSE format',
|
||||
() async {
|
||||
File license = root.childDirectory('third_party').childFile('LICENSE');
|
||||
license.createSync(recursive: true);
|
||||
license.writeAsStringSync(_incorrectLicenseFileText);
|
||||
|
||||
await runner.run(<String>['license-check']);
|
||||
|
||||
// The file shouldn't be checked.
|
||||
expect(printedMessages, isNot(contains('Checking third_party/LICENSE')));
|
||||
expect(printedMessages, contains('All LICENSE files passed validation!'));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const String _correctLicenseFileText =
|
||||
'''Copyright 2017 The Flutter Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
''';
|
||||
|
||||
// A common incorrect version created by copying text intended for a code file,
|
||||
// with comment markers.
|
||||
const String _incorrectLicenseFileText =
|
||||
'''// Copyright 2017 The Flutter Authors. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
''';
|
||||
|
Reference in New Issue
Block a user