Improve parsing of comments without spaces after the #

Better handle cases with empty test scripts
pull/969/head
Jesse Vincent 4 years ago
parent 7e5b05e447
commit 2dd247dae8
No known key found for this signature in database
GPG Key ID: CC228463465E40BC

@ -60,7 +60,7 @@ sub load_from_text {
if ( $line eq '' ) {
next;
}
if ( $line =~ /^(.*?)\s*#\s+(.*)$/ ) {
if ( $line =~ /^(.*?)\s*#\s*(.*)$/ ) {
$line = $1;
$comment = $2;
}
@ -235,8 +235,8 @@ sub generate_script {
elsif ( my $action = $entry->{action} ) {
if ( $action eq 'name' ) { generate_start_new_test($entry) }
elsif ( !$inside_test ) {
die "Attempting to run an action when not inside a test section on line " . $entry->{line_num} . "\n";
elsif ( !$inside_test && defined $action ) {
die "Attempting to run an action '$action' when not inside a test section on line " . $entry->{line_num} . "\n";
}
elsif ( $action eq 'press' ) { generate_press($entry) }
elsif ( $action eq 'release' ) { generate_release($entry); }
@ -248,8 +248,9 @@ sub generate_script {
}
}
generate_end_test();
if ($inside_test) {
generate_end_test();
}
}

Loading…
Cancel
Save