Skip to content

Commit

Permalink
Removed old tests and added two new tests for checking command-line s…
Browse files Browse the repository at this point in the history
…witches
  • Loading branch information
soh-cah-toa committed Jun 20, 2011
1 parent f53a710 commit 918811f
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 153 deletions.
8 changes: 6 additions & 2 deletions frontend/hbdb/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ main(int argc, const char *argv[])
}
}

/* Check for unrecognized options */
if (status == -1)
usage();

/* Setup default initialization parameters */
GET_INIT_STRUCT(initargs);

Expand Down Expand Up @@ -205,7 +209,7 @@ Displays a message about licensing information and resources.
static void
license(void)
{
const char *info = "Copyright (C) 2001-2010, Parrot Foundation.\n"
const char *info = "Copyright (C) 2001-2011, Parrot Foundation.\n"
"This program is distributed under the terms of the "
"Artistic License 2.0\n\n"
"For further information, please see LICENSE or visit "
Expand Down Expand Up @@ -274,7 +278,7 @@ usage(void)
puts(" -h, --help Displays help information");
puts(" -l, --license Displays license information\n");
puts("File:");
puts(" Must be either a bytecode file (.pbc) or PIR file (.pir)");
puts(" May be either a bytecode file (.pbc) or PIR file (.pir)");

exit(EXIT_SUCCESS);
}
Expand Down
82 changes: 0 additions & 82 deletions t/hbdb/main.t

This file was deleted.

30 changes: 0 additions & 30 deletions t/hbdb/main_1.c

This file was deleted.

39 changes: 0 additions & 39 deletions t/hbdb/main_2.c

This file was deleted.

96 changes: 96 additions & 0 deletions t/tools/hbdb.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#! perl

# Copyright (C) 2001-2011, Parrot Foundation.

=head1 NAME
t/tools/hbdb.t - tests for the HBDB debugger
=head1 SYNOPSIS
prove t/tools/hbdb.t
=head1 DESCRIPTION
Tests the C<hbdb> debugger by providing it with a number of source
files and running through it with various commands.
=head1 REQUIREMENTS
This test script requires you to build hbdb, by running "make hbdb". If this
requirement has not been met, all tests will be skipped.
=cut

use warnings;
use strict;

use lib qw/lib/;

use Test::More;
use Parrot::Config;
use Parrot::Test;

my ($path, $exec);

# Check that HBDB has been built first
BEGIN {
$path = File::Spec->join(".", "hbdb");
$exec = $path . $PConfig{'exe'};

# Skip tests if executable doesn't exist
unless (-f $exec) {
plan(skip_all => "HBDB hasn't been built. Please run \"make hbdb\"");
exit(0);
}

plan(tests => 2);
}

my $help_regex = <<OUTPUT;
/Usage: hbdb [[]options[]] [[]file[]]
Options:
(\\s+-.{1},\\s{1}--.*\\s+.*)+
File:
\\s+.*
/m
OUTPUT

# Test that command-line switches are recognized
hbdb_output_like("-h", $help_regex, "HBDB: Help message");

# Test that unknown switches fail correctly
hbdb_output_like("--foobar", $help_regex, "HBDB: Unknown options");

=head1 SUBROUTINES
=over 4
=item C<hbdb_output_like($opt, $rx, $desc)>
Acts as a wrapper around C<like()> to reduce duplicate code. C<$opt> is the
command-line switch to test, C<$rx> is a regular expression to match, and
C<$desc> is a short description.
=cut

sub hbdb_output_like {
my ($opt, $rx, $desc) = @_;
my $out = `$exec $opt`;

like($out, $rx, $desc);
}

=back
=cut

# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4:

0 comments on commit 918811f

Please sign in to comment.