summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2017-05-30 10:52:30 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2017-06-09 07:35:25 +0000
commita8269470a9e21f3e685f25c09e3a92f0ac6615d5 (patch)
treef51bd281438dae3ab52253dab238dac79432a338 /tests
parente8b0477c14f74f9e3098d7ba6300ecbce912efef (diff)
tst_licenses.pl: Make it possible to exclude modules by branch
Change the excludedModules list into a hash which may contain a list reference of excluded branches and prototypically exclude 5.6 of pyside-setup. The 5.6 branch of pyside-setup will not pass the license check when checked against Qt 5.6 since it has a different license. Task-number: PYSIDE-431 Change-Id: Ide9476d84e1c173a61de6eeddcdd56a2aba24897 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/prebuild/license/tst_licenses.pl48
1 files changed, 36 insertions, 12 deletions
diff --git a/tests/prebuild/license/tst_licenses.pl b/tests/prebuild/license/tst_licenses.pl
index 9ef462a8..5b00a36b 100755
--- a/tests/prebuild/license/tst_licenses.pl
+++ b/tests/prebuild/license/tst_licenses.pl
@@ -77,15 +77,15 @@ my $optModuleName;
# These modules are not expected to contain any files that need
# Qt license headers. They are entirely excluded from license checking.
-my @excludedModules = qw{
- qtrepotools
- qtwebkit
- test262
- qtwebengine
- 3rdparty
- qtqa
- pyside-setup
-};
+my %excludedModules = (
+ 'qtrepotools' => [],
+ 'qtwebkit' => [],
+ 'test262' => [],
+ 'qtwebengine' => [],
+ '3rdparty' => [],
+ 'qtqa' => [],
+ 'pyside-setup' => ['5.6']
+);
# If you add to the following lists of regexes, please
# make the patterns as specific as possible to avoid excluding more files
@@ -266,6 +266,16 @@ my $licenseEndMarker = qr/\s\\{0,2}\$QT_END_LICENSE\\{0,2}\$/;
my %licenseTexts; # Map from license name to the associated legal text
my %licenseFiles; # Map from license name to the file defining it for reporting errors
+sub gitBranch
+{
+ my $cmd = 'git "--git-dir=' . $QT_MODULE_TO_TEST . '/.git" branch';
+ for my $line (split(/\n/, `$cmd`)) {
+ chomp($line);
+ return $1 if $line =~ /^\*\s+(.*)$/;
+ }
+ return '';
+}
+
sub loadLicense {
my $licenseFile = shift;
@@ -600,9 +610,23 @@ sub run
$moduleName = defined($optModuleName) ? $optModuleName : basename($QT_MODULE_TO_TEST);
# Skip the test (and return success) if we don't want to scan this module
- if ($optForceTest == 0 && grep { $_ eq $moduleName } @excludedModules) {
- plan skip_all => "$moduleName is excluded from license checks";
- return;
+
+ if ($optForceTest == 0) {
+ my $excludedBranches = $excludedModules{$moduleName};
+ if (defined($excludedBranches)) {
+ if (scalar(@$excludedBranches) > 0) {
+ my $branch = gitBranch();
+ my $quotedBranch = quotemeta($branch);
+ if ($branch ne '' && grep(/$quotedBranch/, @$excludedBranches)) {
+ plan skip_all => 'Branch ' . $branch . ' of ' . $moduleName
+ . ' is excluded from license checks';
+ return;
+ }
+ } else {
+ plan skip_all => $moduleName . ' is excluded from license checks';
+ return;
+ }
+ }
}
#