From 25c3428db2fb439e0a7a2000593b32eeefd4e00f Mon Sep 17 00:00:00 2001 From: Dominique Dumont Date: Wed, 22 Sep 2021 14:20:54 +0200 Subject: test: 'and/or' licenses are seen as used --- t/copyright-from-scratch.t | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) 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"); -- cgit v1.2.3