Implemented error output unit test harness.
--- a/unit_tests/run_tests.pl Wed Mar 03 09:13:26 2010 -0800
+++ b/unit_tests/run_tests.pl Thu Mar 04 22:59:48 2010 -0800
@@ -81,7 +81,31 @@
};
$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;
--- a/utils/mojoshader-compiler.c Wed Mar 03 09:13:26 2010 -0800
+++ b/utils/mojoshader-compiler.c Thu Mar 04 22:59:48 2010 -0800
@@ -126,7 +126,7 @@
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);
@@ -168,7 +168,7 @@
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);