summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominique Dumont <dod@debian.org>2021-09-22 14:20:54 +0200
committerDominique Dumont <dod@debian.org>2021-09-22 14:22:42 +0200
commit25c3428db2fb439e0a7a2000593b32eeefd4e00f (patch)
tree9d325335e836738a93a27b50919d69a690f5842d
parent9085e5404a30a14b6e6d6428cd554c228342cc72 (diff)
test: 'and/or' licenses are seen as used
-rw-r--r--t/copyright-from-scratch.t36
1 files changed, 36 insertions, 0 deletions
diff --git a/t/copyright-from-scratch.t b/t/copyright-from-scratch.t
index f8126e74..fe7adb41 100644
--- a/t/copyright-from-scratch.t
+++ b/t/copyright-from-scratch.t
@@ -62,6 +62,36 @@ subtest 'Creation of debian/copyright' => sub {
$inst->write_back;
};
+subtest 'Check "and/or" statement' => sub {
+ my $inst = $model->instance (
+ root_class_name => 'Dpkg::Copyright',
+ root_dir => $wr_dir,
+ instance_name => "readtest",
+ );
+
+ my $unit = $inst->config_root;
+
+ # write a dummy license
+ $unit->load(q!License:Dummy text="dummy license text"!);
+ # and a dummy entry
+ $unit->load(q!Files:"dummy.c" Copyright="2021 Dod" License short_name="Expat and/or Dummy"!);
+
+ my @unused;
+ $unit->grab("License")->check_unused_licenses([], \@unused);
+ # check fix for a bug where Dummy license was not seen as a used
+ # license in the short name above (because of the 'and/or' and the
+ # fact that Dummy is only used there
+ is(scalar @unused, 0, "all licenses are used");
+
+ # check fix for a bug where Dummy license was removed because it
+ # was only used above and was not seen as a used license in the
+ # short name above.
+ # This triggered a failure to write back copyright.
+ $unit->apply_fixes;
+
+ $inst->write_back;
+};
+
subtest 'Read and check debian/copyright' => sub {
my $inst = $model->instance (
@@ -78,6 +108,12 @@ subtest 'Read and check debian/copyright' => sub {
my $default = $art2_obj->fetch() ;
is_string($default,$art_2_text,"check license text brought by Software::License");
is($art2_obj->fetch_custom,undef,'check lic text');
+
+ is(
+ $unit->grab_value(q!Files:"dummy.c" License short_name!,),
+ "Expat and/or Dummy",
+ "check that 'and/or' statement"
+ );
};
memory_cycle_ok($model, "memory cycles");