Dpkg_BuildFlags.t 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/perl
  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 <https://www.gnu.org/licenses/>.
  15. use strict;
  16. use warnings;
  17. use Test::More tests => 15;
  18. BEGIN {
  19. use_ok('Dpkg::BuildFlags');
  20. }
  21. my $bf = Dpkg::BuildFlags->new();
  22. ok($bf->has('CPPFLAGS'), 'CPPFLAGS is present');
  23. is($bf->get_origin('CPPFLAGS'), 'vendor', 'CPPFLAGS has a vendor origin');
  24. $bf->set('DPKGFLAGS', '-Wflag -On -fsome', 'system');
  25. is($bf->get('DPKGFLAGS'), '-Wflag -On -fsome', 'get flag');
  26. is($bf->get_origin('DPKGFLAGS'), 'system', 'flag has a system origin');
  27. ok(!$bf->is_maintainer_modified('DPKGFLAGS'), 'set marked flag as non-maint modified');
  28. $bf->strip('DPKGFLAGS', '-On', 'user', undef);
  29. is($bf->get('DPKGFLAGS'), '-Wflag -fsome', 'get stripped flag');
  30. is($bf->get_origin('DPKGFLAGS'), 'user', 'flag has a user origin');
  31. ok(!$bf->is_maintainer_modified('DPKGFLAGS'), 'strip marked flag as non-maint modified');
  32. $bf->append('DPKGFLAGS', '-Wl,other', 'vendor', 0);
  33. is($bf->get('DPKGFLAGS'), '-Wflag -fsome -Wl,other', 'get appended flag');
  34. is($bf->get_origin('DPKGFLAGS'), 'vendor', 'flag has a vendor origin');
  35. ok(!$bf->is_maintainer_modified('DPKGFLAGS'), 'append marked flag as non-maint modified');
  36. $bf->prepend('DPKGFLAGS', '-Idir', 'env', 1);
  37. is($bf->get('DPKGFLAGS'), '-Idir -Wflag -fsome -Wl,other', 'get prepended flag');
  38. is($bf->get_origin('DPKGFLAGS'), 'env', 'flag has an env origin');
  39. ok($bf->is_maintainer_modified('DPKGFLAGS'), 'prepend marked flag as maint modified');
  40. # TODO: Add more test cases.
  41. 1;