Skip to content

Commit

Permalink
Feature 1624 OBS_COMMAND (#1625)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnHalleyGotway authored Jan 19, 2021
1 parent 12b0de0 commit 71f94d8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
21 changes: 14 additions & 7 deletions test/perl/unit.pl
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ sub usage {
elsif ($callchk) {
$cmd = "valgrind ".$VALGRIND_OPT_CALL." ".$cmd;
}

# if writing a command file, print the environment and command, then loop
if( $cmd_only ){
print "export $_=\'" . $test->{"env"}{$_} . "\'\n" for sort keys %{ $test->{"env"} };
print "$cmd\n\n";
print "$cmd\n";
print "unset $_\n" for sort keys %{ $test->{"env"} };
print "\n";
next;
}

Expand Down Expand Up @@ -137,23 +139,28 @@ sub usage {

}

# unset the test environment variables
delete $ENV{$_} for keys %{ $test->{"env"} };

# print the test result
printf "%s - %7.3f sec\n", $ret_ok && $out_ok ? "pass" : "FAIL", sprintf("%7.3f", $t_elaps);

# build a list of environment variable exports for reporting
my @envs;
push @envs, "export $_=\'" . $test->{"env"}{$_} . "\'\n" for sort keys %{ $test->{"env"} };
# build a list of environment variable exports and unsets for reporting
my @set_envs;
push @set_envs, "export $_=\'" . $test->{"env"}{$_} . "\'\n" for sort keys %{ $test->{"env"} };
my @unset_envs;
push @unset_envs, "unset $_\n" for sort keys %{ $test->{"env"} };

# if the log file is activated, print the test information
if( $file_log ){
print $fh_log "\n\n";
print $fh_log "$_" for (@envs, @cmd_outs);
print $fh_log "$_" for (@set_envs, @cmd_outs, @unset_envs);
print $fh_log "\n\n";
}

# on failure, print the problematic test and exit, if requested
if( !($ret_ok && $out_ok) ){
print "$_" for (@envs, @cmd_outs);
print "$_" for (@set_envs, @cmd_outs, @unset_envs);
$noexit or exit 1;
print "\n\n";
}
Expand Down
1 change: 1 addition & 0 deletions test/xml/unit_python.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
<exec>&MET_BIN;/point_stat</exec>
<env>
<pair><name>FCST_COMMAND</name> <value>&MET_BASE;/python/read_ascii_numpy.py &DATA_DIR_PYTHON;/fcst.txt FCST</value></pair>
<pair><name>OBS_COMMAND</name> <value>&MET_BASE;/python/read_ascii_numpy.py &DATA_DIR_PYTHON;/obs.txt OBS</value></pair>
</env>
<param> \
PYTHON_NUMPY \
Expand Down

0 comments on commit 71f94d8

Please sign in to comment.