300_Dpkg_BuildOptions.t 1.0 KB

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