Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make test module auto-detection less dynamic #580

Merged
merged 2 commits into from
Oct 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ README.md
share/config_example_logfilter.json
share/iana-ipv4-special-registry.csv
share/iana-ipv6-special-registry.csv
share/modules.txt
share/profile.json
share/profile_example_logfilter.json
share/locale/da/LC_MESSAGES/Zonemaster-Engine.mo
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.SKIP
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
\B\.DS_Store
# Mac OSX SMB mount metadata files
\B\._
# Development mode aid for File::ShareDir
^lib/auto/share/dist/Zonemaster-Engine

# Avoid Devel::Cover and Devel::CoverX::Covered files.
\bcover_db\b
Expand Down
15 changes: 10 additions & 5 deletions lib/Zonemaster/Engine/Test.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@ use Zonemaster::Engine::Test::Basic;

use IO::Socket::INET6; # Lazy-loads, so make sure it's here for the version logging

use Module::Find qw[useall];
use File::ShareDir qw[dist_file];
use File::Slurp qw[read_file];
use Scalar::Util qw[blessed];
use POSIX qw[strftime];

my @all_test_modules;

@all_test_modules =
sort { $a cmp $b }
map { my $f = $_; $f =~ s|^Zonemaster::Engine::Test::||; $f }
grep { $_ ne 'Zonemaster::Engine::Test::Basic' } useall( 'Zonemaster::Engine::Test' );
BEGIN {
@all_test_modules = split /\n/, read_file( dist_file( 'Zonemaster-Engine', 'modules.txt' ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really the best solution? Isn't better to create a perl module that lists the modules? I feel that the code would be simpler and more direct.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just want to fix a bug here. As such I'm trying to change the design as little as possible.

Feel free to create an issue to make the module listing completely static.


for my $name ( @all_test_modules ) {
require "Zonemaster/Engine/Test/$name.pm";
"Zonemaster::Engine::Test::$name"->import();
}
}

sub _log_versions {
info( GLOBAL_VERSION => { version => Zonemaster::Engine->VERSION } );
Expand Down
1 change: 1 addition & 0 deletions lib/auto/share/dist/Zonemaster-Engine
6 changes: 5 additions & 1 deletion share/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ POFILES = $(wildcard *.po)
MOFILES := $(POFILES:.po=.mo)
POTFILE = Zonemaster-Engine.pot
PMFILES = $(shell find ../lib -type f -name '*.pm')
TESTMODULEFILES = $(shell find ../lib/Zonemaster/Engine/Test -type f -name '*.pm')

.PHONY: all update-po extract-pot

all: ${MOFILES}
all: ${MOFILES} modules.txt
@echo
@echo Remember to make sure all of the above names are in the
@echo MANIFEST file, or they will not be installed.
Expand All @@ -26,3 +27,6 @@ $(POTFILE): extract-pot
@# It must be 'Zonemaster-Engine' because that is defined in "name" in Makefile.PL
@perl -e 'use Locale::Msgfmt; msgfmt({in => $$ARGV[0], out => $$ARGV[1]});' $< locale/$*/LC_MESSAGES/Zonemaster-Engine.mo
@echo locale/$*/LC_MESSAGES/Zonemaster-Engine.mo

modules.txt: $(TESTMODULEFILES)
echo $(TESTMODULEFILES) | xargs basename -s .pm -a | grep -vE '^Basic$$' | sort > modules.txt
8 changes: 8 additions & 0 deletions share/modules.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Consistency
Connectivity
Delegation
Syntax
Address
Nameserver
DNSSEC
Zone