300_Dpkg_BuildOptions.t 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # -*- mode: cperl;-*-
  2. use Test::More tests => 6;
  3. use strict;
  4. use warnings;
  5. use_ok('Dpkg::BuildOptions');
  6. {
  7. no warnings;
  8. # Disable warnings related to invalid values fed during
  9. # the tests
  10. $Dpkg::ErrorHandling::quiet_warnings = 1;
  11. }
  12. $ENV{DEB_BUILD_OPTIONS} = 'noopt foonostripbar parallel=3 bazNOCHECK';
  13. my $dbo = Dpkg::BuildOptions::parse();
  14. my %dbo = (
  15. noopt => '',
  16. foonostripbar => '',
  17. parallel => 3,
  18. );
  19. my %dbo2 = (
  20. no => '',
  21. opt => '',
  22. 'no-strip' => '',
  23. nocheck => '',
  24. );
  25. is_deeply($dbo, \%dbo, 'parse');
  26. $dbo = Dpkg::BuildOptions::parse('no opt no-strip parallel = 5 nocheck');
  27. is_deeply($dbo, \%dbo2, 'parse (param)');
  28. $dbo->{parallel} = 5;
  29. $dbo->{noopt} = '';
  30. my $env = Dpkg::BuildOptions::set($dbo, 1);
  31. is($ENV{DEB_BUILD_OPTIONS}, $env, 'set (return value)');
  32. is_deeply(Dpkg::BuildOptions::parse(), $dbo, 'set (env)');
  33. $ENV{DEB_BUILD_OPTIONS} = 'foobar';
  34. $dbo = { noopt => '' };
  35. $env = Dpkg::BuildOptions::set($dbo, 0);
  36. is($env, "foobar noopt", 'set (append)');