Skip to content

Commit a14e79a

Browse files
[Perl] Generated Languages.pm as part of the build process (#176)
The Languages.pm file is now generated upon building the release artifacts or when running the test suite. Fixes: #32 Co-authored-by: M.P. Korstanje <[email protected]>
1 parent 40b4cec commit a14e79a

File tree

8 files changed

+36
-26
lines changed

8 files changed

+36
-26
lines changed

.github/workflows/test-perl.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ jobs:
3838
working-directory: perl
3939

4040
- name: run tests
41-
run: |
42-
prove -l
43-
AUTHOR_TESTS=1 prove -l
41+
run: make test
4442
working-directory: perl
4543

4644
- name: run acceptance tests

perl/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ perl5/
66
.cpanfile_dependencies
77
cpanfile.snapshot
88
CHANGELOG.md
9+
lib/Gherkin/Generated/Languages.pm

perl/Makefile

+24-12
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
SHELL := /usr/bin/env bash
22

33
GHERKIN_PARSER = lib/Gherkin/Generated/Parser.pm
4+
GHERKIN_LANGUAGES = lib/Generated/Languages.pm
45
GHERKIN_RAZOR = gherkin-perl.razor
5-
SOURCE_FILES = $(shell find . -name "*.pm" | grep -v $(GHERKIN_PARSER))
6+
SOURCE_FILES = $(shell find lib -name "*.pm" | grep -v $(GHERKIN_PARSER) | grep -v $(GHERKIN_LANGUAGES) )
67

78
GHERKIN = bin/gherkin
89
GHERKIN_GENERATE_TOKENS = bin/gherkin-generate-tokens
@@ -17,6 +18,11 @@ SOURCES = $(patsubst ../testdata/%,acceptance/testdata/%.source.ndjson,$(GO
1718
ERRORS = $(patsubst ../testdata/%,acceptance/testdata/%.errors.ndjson,$(BAD_FEATURE_FILES))
1819

1920
.DEFAULT_GOAL = help
21+
22+
ARTIFACT_DIR = Gherkin-latest
23+
ARTIFACT_DIR_VERSIONED = Gherkin-$(shell cat VERSION)
24+
ARTIFACT_TAR_GZ = Gherkin-$(shell cat VERSION).tar.gz
25+
2026
PERL5LIB = $$PWD/perl5/lib/perl5
2127
GHERKIN = PERL5LIB=${PERL5LIB} bin/gherkin
2228
GHERKIN_GENERATE_TOKENS = PERL5LIB=${PERL5LIB} bin/gherkin-generate-tokens
@@ -29,30 +35,36 @@ generate: $(GHERKIN_PARSER) ## Generate gherkin parser files
2935
clean-generate: ## Remove generated Gherkin parser files ## Generate gherkin parser files
3036
rm -f $(GHERKIN_PARSER)
3137

32-
copy-gherkin-languages: # lib/Gherkin/Generated/Languages.pm ## Copy gherkin-languages.json and/or generate derived files
33-
echo "TODO: Depends on perl, this task should only depend on jq"
38+
copy-gherkin-languages:
39+
echo "Nothing to do"
3440

3541
clean-gherkin-languages: ## Remove gherkin-languages.json and any derived files
36-
# rm -f lib/Gherkin/Generated/Languages.pm
37-
echo "TODO: Depends on perl, this task should only depend on jq"
42+
echo "Nothing to do"
3843

3944
clean: ## Remove all build artifacts and files generated by the acceptance tests
40-
rm -f .built
45+
rm -rf $(ARTIFACT_DIR_VERSIONED)
46+
rm -rf $(ARTIFACT_DIR)
47+
rm -f $(ARTIFACT_TAR_GZ)
4148
rm -rf acceptance
4249
rm -rf perl5
4350

4451
.DELETE_ON_ERROR:
4552

46-
acceptance: .built $(TOKENS) $(ASTS) $(PICKLES) $(SOURCES) $(ERRORS) ## Build acceptance test dir and compare results with reference
53+
.PHONY: test
54+
test: perl5 ## Runs dzil test
55+
PATH=$$PATH:perl5/bin PERL5LIB=${PERL5LIB} dzil test
56+
57+
acceptance: $(ARTIFACT_DIR) $(TOKENS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES) ## Build acceptance test dir and compare results with reference
4758

48-
.built: perl5 $(SOURCE_FILES)
49-
touch $@
59+
$(ARTIFACT_DIR): $(ARTIFACT_DIR_VERSIONED)
60+
cp -r $(ARTIFACT_DIR_VERSIONED) $@
61+
62+
$(ARTIFACT_DIR_VERSIONED): perl5 $(SOURCE_FILES)
63+
PATH=$$PATH:perl5/bin PERL5LIB=${PERL5LIB} dzil build
5064

5165
perl5:
5266
cpanm --notest --local-lib ./perl5 --installdeps --with-develop .
53-
54-
lib/Gherkin/Generated/Languages.pm:
55-
perl helper-scripts/build_languages.pl > $@
67+
PATH=$$PATH:perl5/bin PERL5LIB=${PERL5LIB} dzil authordeps --missing | cpanm --notest --local-lib ./perl5
5668

5769
$(GHERKIN_PARSER): $(GHERKIN_RAZOR) ../gherkin.berp
5870
berp -g ../gherkin.berp -t $< -o $@ --noBOM

perl/bin/gherkin

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use strict;
44
use warnings;
5-
use lib 'lib';
5+
use lib 'Gherkin-latest/lib';
66

77
use App::gherkin;
88

perl/bin/gherkin-generate-tokens

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use strict;
44
use warnings;
5-
use lib 'lib';
5+
use lib 'Gherkin-latest/lib';
66

77
use Gherkin::Parser;
88
use Gherkin::TokenFormatterBuilder;

perl/cpanfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ on 'test' => sub {
1515
};
1616

1717
on 'develop' => sub {
18-
# there are no specific development dependencies...
18+
requires "Dist::Zilla";
1919
};

perl/dist.ini

+7-1
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,16 @@ exclude_filename=gherkin-perl.razor
3636
exclude_filename=Makefile
3737
exclude_filename=VERSION
3838

39-
[GatherFile]
39+
[GatherFile / CHANGELOG.md]
4040
; explicitly add unversioned files
4141
root=../
4242
filename=CHANGELOG.md
4343

44+
[GatherFile / GeneratedLanguages]
45+
filename=lib/Gherkin/Generated/Languages.pm
46+
4447
[Hook::VersionProvider]
4548
. = my $v = `cat ./VERSION`; chomp( $v ); $v;
49+
50+
[Run::BeforeBuild]
51+
run = helper-scripts/build_languages.pl >lib/Gherkin/Generated/Languages.pm

perl/lib/Gherkin/Generated/Languages.pm

-7
This file was deleted.

0 commit comments

Comments
 (0)