From 342975df0f61741877cbea6c310698dcae7ea6ea Mon Sep 17 00:00:00 2001 From: Graham Ollis Date: Mon, 4 Aug 2025 13:41:51 -0600 Subject: [PATCH 1/4] use $class instead of $self for class methods --- lib/Test/Script.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Test/Script.pm b/lib/Test/Script.pm index 39ae146..eff919c 100644 --- a/lib/Test/Script.pm +++ b/lib/Test/Script.pm @@ -82,7 +82,7 @@ our @EXPORT = qw{ }; sub import { - my $self = shift; + my $class = shift; my $pack = caller; if(defined $_[0] && $_[0] =~ /^(?:no_plan|skip_all|tests)$/) { @@ -104,7 +104,7 @@ sub import { $ctx->release; } foreach ( @EXPORT ) { - $self->export_to_level(1, $self, $_); + $class->export_to_level(1, $class, $_); } } From 5a7e289c893999afec13496c4444d5c2ca06f327 Mon Sep 17 00:00:00 2001 From: Graham Ollis Date: Mon, 4 Aug 2025 13:43:37 -0600 Subject: [PATCH 2/4] bump ci --- .github/workflows/linux.yml | 4 +- .github/workflows/macos.yml | 65 -------------------------------- .github/workflows/windows.yml | 70 ----------------------------------- README.md | 2 +- dist.ini | 2 - 5 files changed, 3 insertions(+), 140 deletions(-) delete mode 100644 .github/workflows/macos.yml delete mode 100644 .github/workflows/windows.yml diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 987620f..4303168 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -41,7 +41,7 @@ jobs: CIP_TAG: ${{ matrix.cip_tag }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Bootstrap CIP run: | @@ -54,7 +54,7 @@ jobs: cip cache-key - name: Cache CPAN modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/.cip key: ${{ runner.os }}-build-${{ steps.cache-key.outputs.key }} diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml deleted file mode 100644 index d2b8134..0000000 --- a/.github/workflows/macos.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: macos - -on: - push: - branches: - - '*' - tags-ignore: - - '*' - pull_request: - -env: - PERL5LIB: /Users/runner/perl5/lib/perl5 - PERL_LOCAL_LIB_ROOT: /Users/runner/perl5 - PERL_MB_OPT: --install_base /Users/runner/perl5 - PERL_MM_OPT: INSTALL_BASE=/Users/runner/perl5 - -jobs: - perl: - - runs-on: macOS-latest - - strategy: - fail-fast: false - - steps: - - uses: actions/checkout@v2 - - - name: Set up Perl - run: | - brew install perl libffi libarchive - curl https://cpanmin.us | perl - App::cpanminus -n - echo "/Users/runner/perl5/bin" >> $GITHUB_PATH - - - name: perl -V - run: perl -V - - - name: Prepare for cache - run: | - perl -V > perlversion.txt - ls -l perlversion.txt - - - name: Cache CPAN modules - uses: actions/cache@v1 - with: - path: ~/perl5 - key: ${{ runner.os }}-build-${{ hashFiles('perlversion.txt') }} - restore-keys: | - ${{ runner.os }}-build-${{ hashFiles('perlversion.txt') }} - - - name: Install Static Dependencies - run: | - cpanm -n Dist::Zilla - dzil authordeps --missing | cpanm -n - dzil listdeps --missing | cpanm -n - - - name: Install Dynamic Dependencies - run: dzil run --no-build 'cpanm --installdeps .' - - - name: Run Tests - run: dzil test -v - - - name: CPAN log - if: ${{ failure() }} - run: | - cat ~/.cpanm/latest-build/build.log diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml deleted file mode 100644 index 913e2d0..0000000 --- a/.github/workflows/windows.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: windows - -on: - push: - branches: - - '*' - tags-ignore: - - '*' - pull_request: - -env: - PERL5LIB: c:\cx\lib\perl5 - PERL_LOCAL_LIB_ROOT: c:/cx - PERL_MB_OPT: --install_base C:/cx - PERL_MM_OPT: INSTALL_BASE=C:/cx - -jobs: - perl: - - runs-on: windows-latest - - strategy: - fail-fast: false - - steps: - - name: Set git to use LF - run: | - git config --global core.autocrlf false - git config --global core.eol lf - - - uses: actions/checkout@v2 - - - name: Set up Perl - run: | - choco install strawberryperl - echo "C:\cx\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - echo "C:\strawberry\c\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - echo "C:\strawberry\perl\site\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - echo "C:\strawberry\perl\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - - - name: Prepare for cache - run: | - perl -V > perlversion.txt - - - name: Cache CPAN modules - uses: actions/cache@v1 - env: - cache-name: cache-cpan-modules - with: - path: c:\cx - key: ${{ runner.os }}-build-${{ hashFiles('perlversion.txt') }} - restore-keys: | - ${{ runner.os }}-build-${{ hashFiles('perlversion.txt') }} - - - name: perl -V - run: perl -V - - - name: Install Static Dependencies - run: | - cpanm -n Dist::Zilla - dzil authordeps --missing | cpanm -n - dzil listdeps --missing | cpanm -n - - - name: Install Dynamic Dependencies - run: dzil run --no-build 'cpanm --installdeps .' - - - name: Run Tests - run: dzil test -v - - diff --git a/README.md b/README.md index 4681173..483d9cd 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Test::Script ![linux](https://github.com/uperl/Test-Script/workflows/linux/badge.svg) ![macos](https://github.com/uperl/Test-Script/workflows/macos/badge.svg) ![windows](https://github.com/uperl/Test-Script/workflows/windows/badge.svg) +# Test::Script ![linux](https://github.com/uperl/Test-Script/workflows/linux/badge.svg) Basic cross-platform tests for scripts diff --git a/dist.ini b/dist.ini index 7c13145..008d7f5 100644 --- a/dist.ini +++ b/dist.ini @@ -13,8 +13,6 @@ test2_v0 = 1 github_user = uperl workflow = linux -workflow = macos -workflow = windows [RemovePrereqs] remove = strict From 5b15e2ab35955d3f173893f1e6b59ab647ede344 Mon Sep 17 00:00:00 2001 From: Graham Ollis Date: Mon, 4 Aug 2025 13:52:58 -0600 Subject: [PATCH 3/4] failing test for gh#45 --- t/bug_gh45.t | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 t/bug_gh45.t diff --git a/t/bug_gh45.t b/t/bug_gh45.t new file mode 100644 index 0000000..c4c00ad --- /dev/null +++ b/t/bug_gh45.t @@ -0,0 +1,90 @@ +use Test2::V0 -no_srand => 1; +use Test::Script (); + +is( + \@Test::Script::EXPORT, + bag { + item $_ for qw( + script_compiles + script_compiles_ok + script_fails + script_runs + script_stdout_is + script_stdout_isnt + script_stdout_like + script_stdout_unlike + script_stderr_is + script_stderr_isnt + script_stderr_like + script_stderr_unlike + program_fails + program_runs + program_stdout_is + program_stdout_isnt + program_stdout_like + program_stdout_unlike + program_stderr_is + program_stderr_isnt + program_stderr_like + program_stderr_unlike + ); + etc; + }, + 'the list of exports contains at least the functions that was defined when this test was created', +); + +not_imported_ok(qw( + script_compiles + script_compiles_ok + script_fails + script_runs + script_stdout_is + script_stdout_isnt + script_stdout_like + script_stdout_unlike + script_stderr_is + script_stderr_isnt + script_stderr_like + script_stderr_unlike + program_fails + program_runs + program_stdout_is + program_stdout_isnt + program_stdout_like + program_stdout_unlike + program_stderr_is + program_stderr_isnt + program_stderr_like + program_stderr_unlike + ), +); + +Test::Script->import('script_compiles', 'script_runs'); + +imported_ok('script_compiles','script_runs'); + +not_imported_ok(qw( + script_compiles_ok + script_fails + script_stdout_is + script_stdout_isnt + script_stdout_like + script_stdout_unlike + script_stderr_is + script_stderr_isnt + script_stderr_like + script_stderr_unlike + program_fails + program_runs + program_stdout_is + program_stdout_isnt + program_stdout_like + program_stdout_unlike + program_stderr_is + program_stderr_isnt + program_stderr_like + program_stderr_unlike + ), +); + +done_testing; From 67e301bd5aff0a055a1302aa842e2abb320cfe3c Mon Sep 17 00:00:00 2001 From: Graham Ollis Date: Mon, 4 Aug 2025 13:57:14 -0600 Subject: [PATCH 4/4] use Exporter if the back compat that you should not be using anyway is not being used --- lib/Test/Script.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Test/Script.pm b/lib/Test/Script.pm index eff919c..e17f4ce 100644 --- a/lib/Test/Script.pm +++ b/lib/Test/Script.pm @@ -46,7 +46,7 @@ use 5.008001; use strict; use warnings; use Carp qw( croak ); -use Exporter; +use Exporter (); use File::Spec; use File::Spec::Unix; use Probe::Perl; @@ -103,8 +103,10 @@ sub import { } $ctx->release; } - foreach ( @EXPORT ) { - $class->export_to_level(1, $class, $_); + else + { + unshift @_, $class; + goto &Exporter::import; } }