From a8149aa8c02f9bd57dd3634ca91a6bfb3b3c063c Mon Sep 17 00:00:00 2001 From: Kang-min Liu Date: Fri, 26 Jul 2024 07:30:05 +0900 Subject: [PATCH] rewrite test cases in command-help.t with Test2 --- t/command-help.t | 61 +++++++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 37 deletions(-) diff --git a/t/command-help.t b/t/command-help.t index d609fbfa..fd36e8f5 100644 --- a/t/command-help.t +++ b/t/command-help.t @@ -1,12 +1,9 @@ #!/usr/bin/env perl -use strict; -use warnings; +use Test2::V0; use FindBin; use lib $FindBin::Bin; use App::perlbrew; -require "test_helpers.pl"; - -use Test::Spec; +require "test2_helpers.pl"; my $bin_perlbrew = file(__FILE__)->dirname->dirname->child("script")->child("perlbrew"); my $perl = $^X; @@ -16,45 +13,35 @@ my $perl = $^X; # that's why we use backtick to test. # - -describe "`perlbrew`" => sub { - it "should print some nice message and instruct user to read help for individual commands" => sub { - my $out = `$perl -Ilib $bin_perlbrew help`; - like $out, qr/perlbrew help /si; - }; +subtest "`perlbrew` should print some nice message and instruct user to read help for individual commands" => sub { + my $out = `$perl -Ilib $bin_perlbrew help`; + like $out, qr/perlbrew help /si; }; -describe "`perlbrew -h`" => sub { - it "should print short version of help message and instruct user to read longer version" => sub { - my $out1 = `$perl -Ilib $bin_perlbrew --help`; - my $out2 = `$perl -Ilib $bin_perlbrew -h`; +subtest "`perlbrew -h` should print short version of help message and instruct user to read longer version" => sub { + my $out1 = `$perl -Ilib $bin_perlbrew --help`; + my $out2 = `$perl -Ilib $bin_perlbrew -h`; - is $out2, $out1; - like $out1, qr/^ See `perlbrew help` for the full documentation/m; - unlike $out1, qr/^CONFIGURATION$/m; - }; + is $out2, $out1; + like $out1, qr/^ See `perlbrew help` for the full documentation/m; + unlike $out1, qr/^CONFIGURATION$/m; }; -describe "`perlbrew help`" => sub { - it "should should the lengthy version " => sub { - my $out = `$perl -Ilib $bin_perlbrew help`; - like $out, qr/^CONFIGURATION$/m; - }; - - it "should instruct user to read help for individual commands." => sub { - my $out = `$perl -Ilib $bin_perlbrew help`; - like $out, qr/perlbrew help /si; - }; +subtest "`perlbrew help` should should the lengthy version " => sub { + my $out = `$perl -Ilib $bin_perlbrew help`; + like $out, qr/^CONFIGURATION$/m; }; -describe "`help install`" => sub { - it "should show the options for install command" => sub { - my $out = `$perl -Ilib $bin_perlbrew help install`; - like $out, qr/^Options for "install" command:/msi; - like $out, qr/--force/si; - like $out, qr/--notest/si; - }; +subtest "`perlbrew help` should instruct user to read help for individual commands." => sub { + my $out = `$perl -Ilib $bin_perlbrew help`; + like $out, qr/perlbrew help /si; }; -runtests unless caller; +subtest "`perlbrew help install` should show the options for install command" => sub { + my $out = `$perl -Ilib $bin_perlbrew help install`; + like $out, qr/^Options for "install" command:/msi; + like $out, qr/--force/si; + like $out, qr/--notest/si; +}; +done_testing;