File tree Expand file tree Collapse file tree 4 files changed +74
-35
lines changed Expand file tree Collapse file tree 4 files changed +74
-35
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,8 @@ clean: ## Remove all build artifacts and files generated by the acceptance tests
43
43
44
44
.DELETE_ON_ERROR :
45
45
46
- acceptance : .built lib/Gherkin/Generated/Languages.pm $(TOKENS ) $(ASTS ) $(PICKLES ) $(SOURCES ) $(ERRORS ) # # Build acceptance test dir and compare results with reference
46
+ acceptance : .built lib/Gherkin/Generated/Languages.pm $(TOKENS ) $(ASTS ) $(PICKLES ) $(SOURCES ) $(ERRORS )
47
+ FEATURE_FILES_BASEDIR=$PWD /../testdata/ dzil test
47
48
48
49
.built : perl5 $(SOURCE_FILES )
49
50
touch $@
@@ -57,16 +58,6 @@ lib/Gherkin/Generated/Languages.pm:
57
58
$(GHERKIN_PARSER ) : $(GHERKIN_RAZOR ) ../gherkin.berp
58
59
berp -g ../gherkin.berp -t $< -o $@ --noBOM
59
60
60
- acceptance/testdata/% .tokens : ../testdata/% ../testdata/% .tokens
61
- mkdir -p $(@D )
62
- $(GHERKIN_GENERATE_TOKENS ) $< > $@
63
- diff --unified $< .tokens $@
64
-
65
- acceptance/testdata/% .ast.ndjson : ../testdata/% ../testdata/% .ast.ndjson
66
- mkdir -p $(@D )
67
- $(GHERKIN ) --no-source --no-pickles --predictable-ids $< | jq --sort-keys --compact-output " ." > $@
68
- diff --unified <( jq " ." $< .ast.ndjson) <( jq " ." $@ )
69
-
70
61
acceptance/testdata/% .pickles.ndjson : ../testdata/% ../testdata/% .pickles.ndjson
71
62
mkdir -p $(@D )
72
63
$(GHERKIN ) --no-source --no-ast --predictable-ids $< | jq --sort-keys --compact-output " ." > $@
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -15,5 +15,6 @@ on 'test' => sub {
15
15
};
16
16
17
17
on ' develop' => sub {
18
- # there are no specific development dependencies...
18
+ requires " File::Find::Rule" ;
19
+ requires " Text::Diff" ;
19
20
};
Original file line number Diff line number Diff line change
1
+ # !perl
2
+
3
+ use strict;
4
+ use warnings;
5
+
6
+ BEGIN {
7
+ use Test2::V0;
8
+
9
+ skip_all ' No AUTHOR_TESTING'
10
+ unless $ENV {AUTHOR_TESTING };
11
+ skip_all ' Missing FEATURE_FILES_BASEDIR'
12
+ unless $ENV {FEATURE_FILES_BASEDIR };
13
+ }
14
+
15
+ use File::Find::Rule;
16
+ use JSON::PP;
17
+
18
+ use App::gherkin;
19
+ use Gherkin::Parser;
20
+ use Gherkin::TokenFormatterBuilder;
21
+
22
+ use Test2::Tools::ClassicCompare qw/ is_deeply / ;
23
+ use Text::Diff;
24
+
25
+ my @good_features =
26
+ File::Find::Rule
27
+ -> file()
28
+ -> name(' *.feature' )
29
+ -> in( File::Spec-> catfile( $ENV {FEATURE_FILES_BASEDIR }, ' good' ) );
30
+
31
+ skip_all ' No test files found'
32
+ unless @good_features ;
33
+
34
+
35
+ # Test tokens
36
+ do {
37
+ my $tp = Gherkin::Parser-> new( Gherkin::TokenFormatterBuilder-> new() );
38
+ for my $feature (@good_features ) {
39
+ subtest " $feature tokens" => sub {
40
+ my $tokens = $tp -> parse( $feature );
41
+ my $str = join ( " \n " , @{ $tokens } ) . " \n " ;
42
+ # compare $tokens string content with content of file "$feature.tokens"
43
+ my $diff = diff \$str , " $feature .tokens" ;
44
+
45
+ ok( not $diff )
46
+ or diag $diff ;
47
+ };
48
+ }
49
+ };
50
+
51
+ # Test AST
52
+ do {
53
+ my $app = App::gherkin-> new;
54
+ $app -> parse_options( qw/ --no-source --no-pickles --predictable-ids/ );
55
+ for my $feature (@good_features ) {
56
+ subtest " $feature AST" => sub {
57
+ my $content ;
58
+ open my $fh , ' >:encoding(UTF-8)' , \$content ;
59
+ local $app -> {out_handle } = $fh ;
60
+ $app -> run( $feature );
61
+ close $fh ;
62
+ my $diff = diff \$content , " $feature .ast.ndjson" ;
63
+
64
+ ok( not $diff )
65
+ or diag $diff ;
66
+ };
67
+ }
68
+ };
69
+
70
+ done_testing;
You can’t perform that action at this time.
0 commit comments