1#!/usr/local/bin/perl
2#
3# Test driver for Term::Query.pm
4#
5use Term::Query qw( query query_table query_table_set_defaults );
6
7use Tester;
8require "Query_Test.pl";
9
10@ARGV = ('all') unless @ARGV;
11
12$Term::Query::Force_Interactive = 1;	# force interactive behaviour
13
14while ($_ = shift) {
15  if    (!index('-debug', $_))		{ $Debug++; }
16  elsif (!index('-details', $_))	{ $Details++; }
17  elsif (!index('-keep', $_))		{ $KeepGoing++; }
18  elsif (!index('-output', $_))		{ $ShowOutput++; }
19  elsif (!index('-help',$_))		{ &usage; }
20  else {
21    $a = $_;
22    run_class_test 'General'	if grep(/^-?$a/i, qw( general all));
23    run_class_test 'Refs'	if grep(/^-?$a/i, qw( refs references all));
24    run_class_test 'Defaults'	if grep(/^-?$a/i, qw( defaults all ));
25    run_class_test 'Tables'	if grep(/^-?$a/i, qw( tables all ));
26    run_class_test 'Subs'	if grep(/^-?$a/i, qw( subs all ));
27  }
28}
29exit;
30
31sub usage {
32    print STDERR <<EOF;
33usage: tq [-options] [class ..]
34options:
35  -debug	Do lots of debugging
36  -details	Show details of the tests (give twice for more details)
37  -keep		Keep going past errors
38  -output	Show output of failed tests (in "t/$TEST.out")
39  -help		This help
40
41"class" is a general class of tests, which are:
42  all		Do all the classes (below)
43  general	Do general query tests
44  references	Do tests on using referenced variables
45  defaults	Do tests on assignment of default values to named variables
46  tables	Do tests of query_table
47  subs		Do tests on "before" and "after" sub references
48
49tq works by running the tests named by \$CLASS (which are just files
50named as "t/\$CLASS.pl").  These classes of tests generate sequences of
51"ok" or "not ok", indexed by an individual test number.  The output
52from each particular indexed test is kept in the file "t/\$TEST.out"
53which is compared against the "reference" output kept in
54"t/\$TEST.ref".  If a comparison fails, then a test is "not ok".  With
55-detail set, the output is shown after the failure.
56
57If you've just installed the Term::Query.pm module, and haven't made
58any changes, then all tests should be "ok".  If you've "enhanced" or
59"fixed" a problem with Term::Query.pm, be sure to run "tq -detail all"
60to perform a regression test.
61
62EOF
63    exit;
64}
65