libcruft-util/test/json.pl

32 lines
564 B
Perl
Raw Normal View History

2011-05-23 17:18:52 +10:00
#!/usr/bin/perl
$COMMAND = "../json-validate";
2011-05-23 17:18:52 +10:00
@good = <json_data/good/*>;
@bad = <json_data/bad/*>;
2011-05-23 17:18:52 +10:00
$success = 1;
sub status_to_str {
$status = shift @_;
return $status ? "failed" : "passed";
}
foreach $testfile(@good) {
$status = system("$COMMAND $testfile &>/dev/null");
$success &&= $status == 0;
printf "%s\t%s\n", status_to_str($status), $testfile;
}
foreach $testfile(@bad) {
$status = system("$COMMAND $testfile &>/dev/null");
$success &&= $status != 0;
printf "%s\t%s\n", status_to_str(!$status), $testfile;
}
exit !$success