Skip to content

Commit 8103a0e

Browse files
committed
Make this work undeer MacOS
- URI is now example.com bc Akamai doesn't block too many checks (MacOS runner was delayed and often hiccuped here) - failed to flush message --prevention - term pattern seems better than the "colorized list"
1 parent 7e97fef commit 8103a0e

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

t/31_isJSON_valid.t

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,27 @@ use JSON;
99

1010
my $tests = 0;
1111
my $prg="./testssl.sh";
12+
my $json="tmp.json";
1213
my $check2run ="--ip=one --ids-friendly -q --color 0";
13-
my $uri="";
14-
my $json="";
14+
my $uri="example.com"; # Cloudflare blocks too often
1515
my $out="";
1616
my $cmd_timeout="--openssl-timeout=10";
17-
# Blacklists we use to trigger an error:
17+
18+
# Patterns used to trigger an error:
1819
my $socket_regex_bl='(e|E)rror|\.\/testssl\.sh: line |(f|F)atal|(c|C)ommand not found';
1920
my $openssl_regex_bl='(e|E)rror|(f|F)atal|\.\/testssl\.sh: line |Oops|s_client connect problem|(c|C)ommand not found';
20-
# that can be done better but I am a perl n00b ;-)
2121
my $os="$^O";
2222

23+
# useful against "failed to flush stdout" messages
24+
STDOUT->autoflush(1);
25+
2326
die "Unable to open $prg" unless -f $prg;
2427

25-
my $uri="cloudflare.com";
28+
# Provide proper start conditions
29+
unlink $json;
2630

31+
# Title
2732
printf "\n%s\n", "Unit testing JSON output ...";
28-
unlink 'tmp.json';
2933

3034
#1
3135
printf "%s\n", ".. plain JSON --> $uri ";
@@ -36,7 +40,6 @@ my @errors=eval { decode_json($json) };
3640
is(@errors,0,"no errors");
3741
$tests++;
3842

39-
4043
#2
4144
printf "%s\n", ".. pretty JSON --> $uri ";
4245
$out = `$prg $check2run --jsonfile-pretty tmp.json $uri`;
@@ -86,15 +89,16 @@ if ( $os eq "linux" ){
8689
printf "skipped two checks on MacOS\n\n";
8790
}
8891

89-
printf "\n";
9092
done_testing($tests);
93+
printf "\n";
9194

9295
sub json($) {
9396
my $file = shift;
9497
$file = `cat $file`;
98+
unlink $file;
9599
return from_json($file);
96100
}
97101

98102

99-
# vim:ts=5:sw=5:expandtab
103+
# vim:ts=5:sw=5:expandtab
100104

0 commit comments

Comments
 (0)