2
###########################################################################
3
## Intent: Unit test to verify uniq.pl
4
###########################################################################
6
##----------------------------##
7
##---] CORE/CPAN INCLUDES [---##
8
##----------------------------##
12
use Getopt::Long; # GetOptions
15
sub BEGIN { plan tests => 12 }
17
##-------------------##
19
##-------------------##
20
our $VERSION = qw(1.0);
22
##------------------##
23
##---] INCLUDES [---##
24
##------------------##
27
##-------------------##
29
##-------------------##
33
###########################################################################
34
## Intent: Run the arch command for output
38
## $? command shell exit status
39
###########################################################################
42
my $cmd = "perl $FindBin::RealBin/../uniq.pl @_";
43
print "Running: $cmd\n" if ($argv{debug});
44
my @tmp = `$cmd 2>&1`;
45
my @output = map{ split(/\s+/o); } @tmp;
46
wantarray ? @output : "@output";
49
###########################################################################
54
###########################################################################
57
print STDERR "Running test: check_uniq\n" if ($argv{debug});
59
# TODO: improve test, uniq.pl regexpr handling not quite right
63
[ '', qw(a a/b a/b/c) ] => [ qw(a a/b a/b/c) ],
64
[ '', qw(a/b a a/b/c) ] => [ qw(a/b a a/b/c) ],
65
[ '', qw(a/b/c a/b a) ] => [ qw(a/b/c a/b a) ],
67
[ '', qw(a a/b a/b/c a/b a) ] => [ qw(a a/b a/b/c) ], # dup removal
69
[ '-s', qw(a a/b a/b/c) ] => [ qw(a a/b a/b/c) ],
70
[ '-s', qw(a/b a a/b/c) ] => [ qw(a a/b a/b/c) ],
71
[ '-s', qw(a/b/c a/b a) ] => [ qw(a a/b a/b/c) ],
73
[ '-r', qw(a a/b a/b/c) ] => [ qw(a) ],
74
[ '-r', qw(a/b a a/b/c) ] => [ qw(a/b a) ],
75
[ '-r', qw(a/b/c a/b a) ] => [ qw(a/b/c a/b a) ],
77
[ '-r', qw(. .. a/b ../a aa/bb) ] => [ qw(. .. a/b aa/bb) ],
78
[ '-r', qw(.. a/b ../a . aa/bb) ] => [ qw(.. a/b . aa/bb) ],
84
my ($a, $b) = splice(@todo, 0, 2);
88
my @out = uniq_pl(@args);
89
# compareExp(\@out, \@exp, 'Failed on line ' . __LINE__ . ", dataset $ct");
93
print STDERR map{ "args> $_\n" }@args;
95
print STDERR map{ "exp> $_\n" }@exp;
97
print STDERR map{ "out> $_\n" }@out;
100
ok("@out", "@exp", 'Failed on line ' . __LINE__ . ", dataset $ct");
106
###########################################################################
107
## Intent: Smoke tests for the unittests module
108
###########################################################################
111
print STDERR "Running test: smoke()\n" if ($argv{debug});
114
###########################################################################
115
## Intent: Intitialize global test objects and consts
116
###########################################################################
119
print "Running: init()\n" if ($argv{debug});
126
unless(GetOptions(\%argv,
135
print " --debug Enable script debug mode\n";
136
print " --fail Force a testing failure condition\n";
137
print " --manual Also run disabled tests\n";
138
print " --smoke Run smoke tests then exit\n";
139
print " --test Run a list of tests by function name\n";
140
print " --verbose Enable script verbose mode\n";
145
testbyname(@{ $argv{test} }) if ($argv{test});
149
ok(1, 0, 'Forced failure by command line arg --fail') if ($argv{fail});