From 7c06c750c83e612790c05cc51df45d85c5e46bfd Mon Sep 17 00:00:00 2001 From: Nick Logan Date: Wed, 1 Nov 2023 20:01:33 -0500 Subject: [PATCH] Remove prove test plugin One reason this is being removed is in the spirit of dogfooding: if one wants to use a test harness they should use the Raku one which allows us to get back structured information. Another reason is this plugin makes it difficult to pass in the includes paths. Previous we were just setting RAKULIB, but that is causing issues since we changed to using a staging installation workflow. --- .appveyor.yml | 6 +- .circleci/config.yml | 6 +- META6.json | 1 - lib/Zef/CLI.rakumod | 3 + lib/Zef/Service/Shell/Test.rakumod | 2 +- lib/Zef/Service/Shell/prove.rakumod | 149 ---------------------------- lib/Zef/Service/TAP.rakumod | 4 +- lib/Zef/Test.rakumod | 2 +- resources/config.json | 4 - t/00-load.rakutest | 1 - 10 files changed, 11 insertions(+), 167 deletions(-) delete mode 100644 lib/Zef/Service/Shell/prove.rakumod diff --git a/.appveyor.yml b/.appveyor.yml index 7027d617..d1d7c4ef 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -33,10 +33,8 @@ test_script: - raku -I. xt/repository.rakutest - raku -I. xt/install.rakutest - # test explicitly via `prove t/*` and `raku t/foo.rakutest && raku t/bar.rakutest` - # both should work, since all our CI envs have prove - - raku -I. bin/zef --debug --/tap-harness --/prove --raku-test test . - - raku -I. bin/zef --debug --/tap-harness --prove --/raku-test test . + # test zef test + - raku -I. bin/zef --debug --raku-test test . # run relative local path test + install - raku -I. bin/zef --debug install . diff --git a/.circleci/config.yml b/.circleci/config.yml index f2e94287..823e19f7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -23,10 +23,8 @@ variables: raku -I. xt/repository.rakutest raku -I. xt/install.rakutest - # test explicitly via `prove t/*` and `raku t/foo.rakutest && raku t/bar.rakutest` - # both should work, since all our CI envs have prove - raku -I. bin/zef --debug --/tap-harness --/prove --raku-test test . - raku -I. bin/zef --debug --/tap-harness --prove --/raku-test test . + # test zef test + raku -I. bin/zef --debug test . # run relative local path test + install raku -I. bin/zef --debug install . diff --git a/META6.json b/META6.json index 9ac81c5b..4e97b15b 100644 --- a/META6.json +++ b/META6.json @@ -40,7 +40,6 @@ "Zef::Service::Shell::LegacyBuild" : "lib/Zef/Service/Shell/LegacyBuild.rakumod", "Zef::Service::Shell::Test" : "lib/Zef/Service/Shell/Test.rakumod", - "Zef::Service::Shell::prove" : "lib/Zef/Service/Shell/prove.rakumod", "Zef::Service::Shell::unzip" : "lib/Zef/Service/Shell/unzip.rakumod", "Zef::Service::Shell::tar" : "lib/Zef/Service/Shell/tar.rakumod", "Zef::Service::Shell::curl" : "lib/Zef/Service/Shell/curl.rakumod", diff --git a/lib/Zef/CLI.rakumod b/lib/Zef/CLI.rakumod index 3432b131..23a994e0 100644 --- a/lib/Zef/CLI.rakumod +++ b/lib/Zef/CLI.rakumod @@ -311,6 +311,9 @@ package Zef::CLI { note 'DEPRECATED: --depsonly is deprecated, please use --deps-only instead'; take '--deps-only' } + elsif $arg eq '--prove' || $arg eq '--/prove' { + note "DEPRECATED: $arg will be ignored: The prove plugin has been removed and $arg may issue an error in the future."; + } else { take $arg } diff --git a/lib/Zef/Service/Shell/Test.rakumod b/lib/Zef/Service/Shell/Test.rakumod index d5109a4b..c0b6459b 100644 --- a/lib/Zef/Service/Shell/Test.rakumod +++ b/lib/Zef/Service/Shell/Test.rakumod @@ -62,7 +62,7 @@ class Zef::Service::Shell::Test does Tester { method test(IO() $path, Str :@includes, Supplier :$stdout, Supplier :$stderr --> Bool:D) Test the files ending in C<.rakutest> C<.t6> or C<.t> in the C directory of the given C<$path> using the - provided C<@includes> (e.g. C or C) via the C command. A C can be + provided C<@includes> (e.g. C or C) via the C command. A C can be supplied as C<:$stdout> and C<:$stderr> to receive any output. Returns C if all test files exited with 0. diff --git a/lib/Zef/Service/Shell/prove.rakumod b/lib/Zef/Service/Shell/prove.rakumod deleted file mode 100644 index 54fab19c..00000000 --- a/lib/Zef/Service/Shell/prove.rakumod +++ /dev/null @@ -1,149 +0,0 @@ -use Zef:ver($?DISTRIBUTION.meta // $?DISTRIBUTION.meta// '*'):api($?DISTRIBUTION.meta // '*'):auth($?DISTRIBUTION.meta // ''); - -class Zef::Service::Shell::prove does Tester { - - =begin pod - - =title class Zef::Service::Shell::prove - - =subtitle A prove based implementation of the Tester interface - - =head1 Synopsis - - =begin code :lang - - use Zef; - use Zef::Service::Shell::prove; - - my $prove = Zef::Service::Shell::prove.new; - - # Add logging if we want to see output - my $stdout = Supplier.new; - my $stderr = Supplier.new; - $stdout.Supply.tap: { say $_ }; - $stderr.Supply.tap: { note $_ }; - - # Assuming our current directory is a raku distribution - # with no dependencies or all dependencies already installed... - my $dist-to-test = $*CWD; - my Str @includes = $*CWD.absolute; - my $passed = so $prove.test($dist-to-test, :@includes, :$stdout, :$stderr); - say $passed ?? "PASS" !! "FAIL"; - - =end code - - =head1 Description - - C class for handling path based URIs ending in .rakutest / .t6 / .t using the C command. - - You probably never want to use this unless its indirectly through C; - handling files and spawning processes will generally be easier using core language functionality. This - class exists to provide the means for fetching a file using the C interfaces that the e.g. Test/TAP - adapters use. - - =head1 Methods - - =head2 method probe - - method probe(--> Bool:D) - - Returns C if this module can successfully launch the C command. - - =head2 method test-matcher - - method test-matcher(Str() $uri --> Bool:D) - - Returns C if this module knows how to test C<$uri>, which it decides based on if C<$uri> exists - on local file system. - - =head2 method test - - method test(IO() $path, Str :@includes, Supplier :$stdout, Supplier :$stderr --> Bool:D) - - Test the files ending in C<.rakutest> C<.t6> or C<.t> in the C directory of the given C<$path> using the - provided C<@includes> (e.g. C or C) via the C command. A C can be - supplied as C<:$stdout> and C<:$stderr> to receive any output. - - Returns C if all tests passed according to C. - - =end pod - - my Lock $probe-lock = Lock.new; - my Bool $probe-cache; - - #| Return true if the `prove` command is available to use - method probe(--> Bool:D) { - $probe-lock.protect: { - return $probe-cache if $probe-cache.defined; - my $probe = self!probe; - return $probe-cache = $probe; - } - } - - method !probe(--> Bool:D) { - if $*EXECUTABLE.absolute.contains(" ") { - # prove can't deal with spaces in the executable path. - # It assumes everything after the first space to be args to the - # executable. So we can't use prove if our executables path - # contains a space. Sad. - # https://metacpan.org/dist/Test-Harness/view/bin/prove#-exec - return False - } - # `prove --help` has exitcode == 1 unlike most other processes - # so it requires a more convoluted probe check - try { - my $proc = $*DISTRO.is-win - ?? Zef::zrun('prove.bat', '--help', :out, :!err) - !! Zef::zrun('prove', '--help', :out, :!err); - my @out = $proc.out.lines; - $proc.out.close; - CATCH { - when X::Proc::Unsuccessful { - return True if $proc.exitcode == 1 && @out.first(*.contains("-exec" | "Mac OS")); - } - default { return False } - } - } - # Should't reach here based on prior exitcode comment - return False; - } - - #| Return true if this Tester understands the given uri/path - method test-matcher(Str() $uri --> Bool:D) { return $uri.IO.e } - - #| Test the given paths t/ directory using any provided @includes - method test(IO() $path, Str :@includes, Supplier :$stdout, Supplier :$stderr --> Bool:D) { - die "cannot test path that does not exist: {$path}" unless $path.e; - my $test-path = $path.child('t'); - return True unless $test-path.e; - - my Str $test-path-relative = $test-path.relative($path); - my Str $test-path-cwd = $path.absolute; - - my %ENV = %*ENV; - my @cur-lib = %ENV.?chars ?? %ENV.split($*DISTRO.cur-sep) !! (); - %ENV = (|@includes, |@cur-lib).join($*DISTRO.cur-sep); - - my @args = - '--ext', '.rakutest', - '--ext', '.t', - '--ext', '.t6', - '-r', - ('--verbose' if %*ENV), - ; - my $passed; - react { - my $proc = $*DISTRO.is-win - ?? Proc::Async.new(:win-verbatim-args, 'prove.bat', |@args, '-e', - '"' ~ $*EXECUTABLE.absolute ~ '"', - '"' ~ $test-path-relative ~ '"') - !! Proc::Async.new('prove', |@args, '-e', - $*EXECUTABLE.absolute, - $test-path-relative); - whenever $proc.stdout.lines { $stdout.emit($_) } - whenever $proc.stderr.lines { $stderr.emit($_) } - whenever $proc.start(:%ENV, :cwd($test-path-cwd)) { $passed = $_.so } - } - return so $passed; - } -} diff --git a/lib/Zef/Service/TAP.rakumod b/lib/Zef/Service/TAP.rakumod index 3d7e3fa9..a157a019 100644 --- a/lib/Zef/Service/TAP.rakumod +++ b/lib/Zef/Service/TAP.rakumod @@ -39,8 +39,8 @@ class Zef::Service::TAP does Tester { You probably never want to use this unless its indirectly through C; handling files and spawning processes will generally be easier using core language functionality. This - class exists to provide the means for fetching a file using the C interfaces that the e.g. Test/prove - adapters use. + class exists to provide the means for fetching a file using the C interfaces that the e.g. Test + adapter uses. =head1 Methods diff --git a/lib/Zef/Test.rakumod b/lib/Zef/Test.rakumod index 1f3d7609..47bbcbd0 100644 --- a/lib/Zef/Test.rakumod +++ b/lib/Zef/Test.rakumod @@ -19,7 +19,7 @@ class Zef::Test does Tester does Pluggable { # Setup with a single tester backend my $tester = Zef::Test.new( backends => [ - { module => "Zef::Service::Shell::prove" }, + { module => "Zef::Service::Shell::Test" }, ], ); diff --git a/resources/config.json b/resources/config.json index 31a8b775..0a6d6ac7 100644 --- a/resources/config.json +++ b/resources/config.json @@ -147,10 +147,6 @@ "module" : "Zef::Service::TAP", "comment" : "Raku TAP::Harness adapter" }, - { - "short-name" : "prove", - "module" : "Zef::Service::Shell::prove" - }, { "short-name" : "raku-test", "module" : "Zef::Service::Shell::Test" diff --git a/t/00-load.rakutest b/t/00-load.rakutest index 650a4930..6c92ba36 100644 --- a/t/00-load.rakutest +++ b/t/00-load.rakutest @@ -35,7 +35,6 @@ subtest 'Plugins' => { use-ok("Zef::Service::Shell::DistributionBuilder"); use-ok("Zef::Service::Shell::LegacyBuild"); use-ok("Zef::Service::Shell::Test"); - use-ok("Zef::Service::Shell::prove"); use-ok("Zef::Service::Shell::unzip"); use-ok("Zef::Service::Shell::tar"); use-ok("Zef::Service::Shell::curl");