Skip to content

Commit

Permalink
Test line numbers for failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
usev6 committed Apr 2, 2015
1 parent 493af7f commit 4317b37
Show file tree
Hide file tree
Showing 15 changed files with 180 additions and 0 deletions.
57 changes: 57 additions & 0 deletions S24-testing/line-numbers.t
@@ -0,0 +1,57 @@
use v6;
use Test;

plan 13;

my $dir = 't/spec/S24-testing/test-data/';
my $prefix = 'line-number-';
my $suffix = '.txt';

my $cmd;
my $full-path;

sub execute-test ( :$function, :$line ) {
$full-path = $dir ~ $prefix ~ $function ~ $suffix;
$cmd = "$*EXECUTABLE $full-path 2>&1";
ok qqx[$cmd] ~~ /'Failed test ' (\N* \n \N*)? 'at ' $full-path ' line ' $line/,
"failing test with $function reports correct line number $line";
}

#?DOES 1
execute-test(:function("cmp_ok"), :line(9));

#?DOES 1
execute-test(:function("dies_ok"), :line(9));

#?DOES 1
execute-test(:function("eval_dies_ok"), :line(9));

#?DOES 1
execute-test(:function("eval_lives_ok"), :line(9));

#?DOES 1
execute-test(:function("isa_ok"), :line(9));

#?DOES 1
execute-test(:function("is_approx"), :line(9));

#?DOES 1
execute-test(:function("is_deeply"), :line(9));

#?DOES 1
execute-test(:function("isnt"), :line(9));

#?DOES 1
execute-test(:function("is"), :line(9));

#?DOES 1
execute-test(:function("lives_ok"), :line(9));

#?DOES 1
execute-test(:function("nok"), :line(9));

#?DOES 1
execute-test(:function("ok"), :line(9));

#?DOES 1
execute-test(:function("throws_like"), :line(9));
6 changes: 6 additions & 0 deletions S24-testing/test-data/README
@@ -0,0 +1,6 @@
t/spec/S24-testing/test-data/README

This directory exists to hold files which are used
by tests in S24-testing.
The files in this directorey are not supposed to
be run directly.
9 changes: 9 additions & 0 deletions S24-testing/test-data/line-number-cmp_ok.txt
@@ -0,0 +1,9 @@
use v6;
use Test;

plan 1;

## the following code should stay at line number 9
## if you move it to another line, please adjust
## the line number in S24-testing/line-numbers.t
cmp_ok 'foo', 'eq', 'bar';
9 changes: 9 additions & 0 deletions S24-testing/test-data/line-number-dies_ok.txt
@@ -0,0 +1,9 @@
use v6;
use Test;

plan 1;

## the following code should stay at line number 9
## if you move it to another line, please adjust
## the line number in S24-testing/line-numbers.t
dies_ok { 1 };
9 changes: 9 additions & 0 deletions S24-testing/test-data/line-number-eval_dies_ok.txt
@@ -0,0 +1,9 @@
use v6;
use Test;

plan 1;

## the following code should stay at line number 9
## if you move it to another line, please adjust
## the line number in S24-testing/line-numbers.t
eval_dies_ok '1';
9 changes: 9 additions & 0 deletions S24-testing/test-data/line-number-eval_lives_ok.txt
@@ -0,0 +1,9 @@
use v6;
use Test;

plan 1;

## the following code should stay at line number 9
## if you move it to another line, please adjust
## the line number in S24-testing/line-numbers.t
eval_lives_ok 'die';
9 changes: 9 additions & 0 deletions S24-testing/test-data/line-number-is.txt
@@ -0,0 +1,9 @@
use v6;
use Test;

plan 1;

## the following code should stay at line number 9
## if you move it to another line, please adjust
## the line number in S24-testing/line-numbers.t
is 'foo', 'bar';
9 changes: 9 additions & 0 deletions S24-testing/test-data/line-number-is_approx.txt
@@ -0,0 +1,9 @@
use v6;
use Test;

plan 1;

## the following code should stay at line number 9
## if you move it to another line, please adjust
## the line number in S24-testing/line-numbers.t
is_approx 1, 2;
9 changes: 9 additions & 0 deletions S24-testing/test-data/line-number-is_deeply.txt
@@ -0,0 +1,9 @@
use v6;
use Test;

plan 1;

## the following code should stay at line number 9
## if you move it to another line, please adjust
## the line number in S24-testing/line-numbers.t
is_deeply <foo bar>, <baz>;
9 changes: 9 additions & 0 deletions S24-testing/test-data/line-number-isa_ok.txt
@@ -0,0 +1,9 @@
use v6;
use Test;

plan 1;

## the following code should stay at line number 9
## if you move it to another line, please adjust
## the line number in S24-testing/line-numbers.t
isa_ok Str, Num;
9 changes: 9 additions & 0 deletions S24-testing/test-data/line-number-isnt.txt
@@ -0,0 +1,9 @@
use v6;
use Test;

plan 1;

## the following code should stay at line number 9
## if you move it to another line, please adjust
## the line number in S24-testing/line-numbers.t
isnt 'foo', 'foo';
9 changes: 9 additions & 0 deletions S24-testing/test-data/line-number-lives_ok.txt
@@ -0,0 +1,9 @@
use v6;
use Test;

plan 1;

## the following code should stay at line number 9
## if you move it to another line, please adjust
## the line number in S24-testing/line-numbers.t
lives_ok { die };
9 changes: 9 additions & 0 deletions S24-testing/test-data/line-number-nok.txt
@@ -0,0 +1,9 @@
use v6;
use Test;

plan 1;

## the following code should stay at line number 9
## if you move it to another line, please adjust
## the line number in S24-testing/line-numbers.t
nok 1;
9 changes: 9 additions & 0 deletions S24-testing/test-data/line-number-ok.txt
@@ -0,0 +1,9 @@
use v6;
use Test;

plan 1;

## the following code should stay at line number 9
## if you move it to another line, please adjust
## the line number in S24-testing/line-numbers.t
ok 0;
9 changes: 9 additions & 0 deletions S24-testing/test-data/line-number-throws_like.txt
@@ -0,0 +1,9 @@
use v6;
use Test;

plan 1;

## the following code should stay at line number 9
## if you move it to another line, please adjust
## the line number in S24-testing/line-numbers.t
throws_like { X::Syntax::Confused }, X::AdHoc;

0 comments on commit 4317b37

Please sign in to comment.