summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/pkglint/files/pkglint.t39
1 files changed, 36 insertions, 3 deletions
diff --git a/pkgtools/pkglint/files/pkglint.t b/pkgtools/pkglint/files/pkglint.t
index 9bf22abd82c..d34e24a6964 100644
--- a/pkgtools/pkglint/files/pkglint.t
+++ b/pkgtools/pkglint/files/pkglint.t
@@ -1,5 +1,5 @@
#! @PERL@
-# $NetBSD: pkglint.t,v 1.2 2013/01/20 02:57:37 schmonz Exp $
+# $NetBSD: pkglint.t,v 1.3 2013/01/20 03:50:05 schmonz Exp $
#
require 'pkglint.pl'; # so we can test its internals
@@ -7,7 +7,7 @@ $main::program = 'pkglint.pl'; # because it self-greps for vartypes
package PkgLint::Test; # pkglint.pl uses 'main', so we mustn't
-use Test::More tests => 17;
+use Test::More tests => 28;
use Test::Trap;
use warnings;
@@ -34,8 +34,33 @@ sub test_get_vartypes_basictypes {
my @results = test_unit($unit, undef, undef, '^$', '^$');
my %types = %{$results[0]};
- is($types{YesNo_Indirectly}, 1, q{a couple expected types are here});
is($types{BuildlinkDepmethod}, 1, q{a couple expected types are here});
+ is($types{YesNo_Indirectly}, 1, q{a couple expected types are here});
+}
+
+sub test_get_vartypes_map {
+ my $unit = \&main::get_vartypes_map;
+
+ my @results = test_unit($unit, undef, undef, '^$', '^$');
+ my %map = %{$results[0]};
+ is($map{'BSD_MAKE_ENV'}->basic_type(), 'ShellWord',
+ q{a couple expected vars are typed right});
+ is($map{'USE_BUILTIN.*'}->basic_type(), 'YesNo_Indirectly',
+ q{a couple expected vars are typed right});
+}
+
+sub test_checkline_mk_vartype_basic {
+ # this is what gets self-grepped: all that "elsif ($type eq"
+ # sub doesn't return anything, just warns or errors if need be
+ #
+ # TODO:
+ #
+ # test a shallow one and then a deeply nested one
+ # (type='Restricted', value='incorrect')
+ # (type='Restricted', value='RESTRICTED')
+ # (type='SedCommands', a few different values')
+ # once test coverage is persuasive, refactor to a dispatch table
+ # once refactored, get rid of the $main::program global
}
sub test_main {
@@ -52,10 +77,18 @@ sub test_main {
@ARGV = ('..');
test_unit($unit, undef, 1, '^ERROR:.+LICENSE', '^$');
+
+ @ARGV = ('/does/not/exist');
+ test_unit($unit, undef, 1, '^ERROR:.+not exist', '^$');
+
+ @ARGV = ($ENV{HOME});
+ test_unit($unit, undef, 1, '^ERROR:.+outside a pkgsrc', '^$');
}
sub main {
test_get_vartypes_basictypes();
+ test_get_vartypes_map();
+ test_checkline_mk_vartype_basic();
test_main();
}