Skip to content

Commit

Permalink
Implemented error output unit test harness.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Mar 5, 2010
1 parent 59a357d commit 6fbb285
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
26 changes: 25 additions & 1 deletion unit_tests/run_tests.pl
Expand Up @@ -81,7 +81,31 @@ sub compare_files {
};

$tests{'errors'} = sub {
return (-1, 'Unimplemented'); # !!! FIXME
my ($module, $fname) = @_;
my $error_output = 'unittest_temperroutput';
my $output = 'unittest_tempoutput';
my $desired = $fname . '.correct';
my $cmd = undef;
my $endlines = 1;

# !!! FIXME: this should go elsewhere.
if ($module eq 'preprocessor') {
$cmd = "$binpath/mojoshader-compiler -P '$fname' -o '$output'";
} else {
return (0, "Don't know how to do this module type");
}
$cmd .= " 2>$error_output 1>/dev/null";

print("$cmd\n") if ($GPrintCmds);

system($cmd);
unlink($output) if (-f $output);

if (not -f $error_output) { return (0, "Didn't get any error output"); }

my @retval = compare_files($desired, $error_output, $endlines);
unlink($error_output);
return @retval;
};

my $totaltests = 0;
Expand Down
4 changes: 2 additions & 2 deletions utils/mojoshader-compiler.c
Expand Up @@ -126,7 +126,7 @@ static int preprocess(const char *fname, const char *buf, int len,
int i;
for (i = 0; i < pd->error_count; i++)
{
printf("%s:%d: ERROR: %s\n",
fprintf(stderr, "%s:%d: ERROR: %s\n",
pd->errors[i].filename ? pd->errors[i].filename : "???",
pd->errors[i].error_position,
pd->errors[i].error);
Expand Down Expand Up @@ -168,7 +168,7 @@ static int assemble(const char *fname, const char *buf, int len,
int i;
for (i = 0; i < pd->error_count; i++)
{
printf("%s:%d: ERROR: %s\n",
fprintf(stderr, "%s:%d: ERROR: %s\n",
pd->errors[i].filename ? pd->errors[i].filename : "???",
pd->errors[i].error_position,
pd->errors[i].error);
Expand Down

0 comments on commit 6fbb285

Please sign in to comment.