300_Dpkg_BuildOptions.t 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # -*- mode: cperl;-*-
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 2 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. use Test::More tests => 6;
  16. use Dpkg::ErrorHandling;
  17. use strict;
  18. use warnings;
  19. use_ok('Dpkg::BuildOptions');
  20. {
  21. no warnings;
  22. # Disable warnings related to invalid values fed during
  23. # the tests
  24. report_options(quiet_warnings => 1);
  25. }
  26. $ENV{DEB_BUILD_OPTIONS} = 'noopt foonostripbar parallel=3 bazNOCHECK';
  27. my $dbo = Dpkg::BuildOptions::parse();
  28. my %dbo = (
  29. noopt => '',
  30. foonostripbar => '',
  31. parallel => 3,
  32. );
  33. my %dbo2 = (
  34. no => '',
  35. opt => '',
  36. 'no-strip' => '',
  37. nocheck => '',
  38. );
  39. is_deeply($dbo, \%dbo, 'parse');
  40. $dbo = Dpkg::BuildOptions::parse('no opt no-strip parallel = 5 nocheck');
  41. is_deeply($dbo, \%dbo2, 'parse (param)');
  42. $dbo->{parallel} = 5;
  43. $dbo->{noopt} = '';
  44. my $env = Dpkg::BuildOptions::set($dbo, 1);
  45. is($ENV{DEB_BUILD_OPTIONS}, $env, 'set (return value)');
  46. is_deeply(Dpkg::BuildOptions::parse(), $dbo, 'set (env)');
  47. $ENV{DEB_BUILD_OPTIONS} = 'foobar';
  48. $dbo = { noopt => '' };
  49. $env = Dpkg::BuildOptions::set($dbo, 0);
  50. is($env, "foobar noopt", 'set (append)');