# Detect the distribution in use
%global __despace head -n 1 | tr -d '[:space:]' | sed -e 's/[(].*[)]//g'
%global __lower4 cut -c 1-4 | tr '[:upper:]' '[:lower:]'
%global __distfile %([ -f /etc/SuSE-release ] && echo /etc/SuSE-release || echo /etc/redhat-release)
%global __distinit %(sed -e 's/ release .*//' -e 's/\\([A-Za-z]\\)[^ ]*/\\1/g' %{__distfile} | %{__despace} | %{__lower4})
%global __distvers %(sed -e 's/.* release \\([^. ]*\\).*/\\1/' %{__distfile} | %{__despace})
# Identify Alma, CentOS, CentOS Stream and Rocky Linux as rhel
%if "%{__distinit}" == "a" || "%{__distinit}" == "c" || "%{__distinit}" == "cl" || "%{__distinit}" == "cs" || "%{__distinit}" == "rl"
%global __distinit rhel
%endif
# Dist tag for Fedora is still "fc"
%if "%{__distinit}" == "f"
%global __distinit fc
%endif

Name:		perl-Test-Script
Version:	1.29
Release:	8.%{__distinit}%{__distvers}
Summary:	Cross-platform basic tests for scripts
License:	GPL-1.0-or-later OR Artistic-1.0-Perl
URL:		https://metacpan.org/release/Test-Script
Source0:	https://cpan.metacpan.org/modules/by-module/Test/Test-Script-%{version}.tar.gz
BuildArch:	noarch
# Module Build
BuildRequires:	coreutils
BuildRequires:	findutils
BuildRequires:	make
BuildRequires:	perl-generators
BuildRequires:	perl-interpreter
BuildRequires:	perl(ExtUtils::MakeMaker)
# Module Runtime
BuildRequires:	perl(Capture::Tiny)
BuildRequires:	perl(Carp)
BuildRequires:	perl(Exporter)
BuildRequires:	perl(File::Spec) >= 0.80
BuildRequires:	perl(File::Spec::Unix)
BuildRequires:	perl(File::Temp)
BuildRequires:	perl(IO::Handle)
BuildRequires:	perl(Probe::Perl) >= 0.01
BuildRequires:	perl(strict)
BuildRequires:	perl(Test2::API) >= 1.302015
BuildRequires:	perl(Test2::V0) >= 0.000060
BuildRequires:	perl(Text::ParseWords)
BuildRequires:	perl(warnings)
# Test Suite
BuildRequires:	perl(Config)
BuildRequires:	perl(Data::Dumper)
BuildRequires:	perl(Test::More)
# Dependencies
%if 0%{?fedora} < 38 && 0%{?rhel} < 10
Requires:	perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version))
%endif
Requires:	perl(Text::ParseWords)

%description
The intent of this module is to provide a series of basic tests for scripts
in the bin directory of your Perl distribution.

%prep
%setup -q -n Test-Script-%{version}

%build
perl Makefile.PL INSTALLDIRS=vendor
make %{?_smp_mflags}

%install
make pure_install DESTDIR=%{buildroot}
find %{buildroot} -type f -name .packlist -delete
%{_fixperms} -c %{buildroot}

%check
make test

%files
%license LICENSE
%doc Changes README
%{perl_vendorlib}/Test/
%{_mandir}/man3/Test::Script.3*

%changelog
* Mon Jun 26 2023 Paul Howarth <paul@city-fan.org> - 1.29-8
- Use SPDX-format license tag

* Fri May 14 2021 Paul Howarth <paul@city-fan.org> - 1.29-1
- Update to 1.29
  - Added script_fails and program_fails functions (GH#34, GH#38)

* Thu Feb 18 2021 Paul Howarth <paul@city-fan.org> - 1.27-1
- Update to 1.27
  - Documentation improvements (GH#30, GH#31)
- Use %%license unconditionally

* Sun Oct 27 2019 Paul Howarth <paul@city-fan.org> - 1.26-1
- Update to 1.26
  - Add program_runs and related functions for testing programs that do not
    run under Perl (GH#26, GH#27)

* Mon Sep  9 2019 Paul Howarth <paul@city-fan.org> - 1.25-5
- Test2::V0 is a module dependency, not a test dependency

* Fri Jun  7 2019 Paul Howarth <paul@city-fan.org> - 1.25-3
- Perl 5.30 rebuild

* Fri Sep 28 2018 Paul Howarth <paul@city-fan.org> - 1.25-1
- Update to 1.25
  - Add interpreter_options to script_runs options
- Switch upstream from search.cpan.org to metacpan.org

* Tue Jul 18 2017 Paul Howarth <paul@city-fan.org> - 1.23-1
- Update to 1.23
  - Migrate to using Test2::V0 internally

* Fri Jul 14 2017 Paul Howarth <paul@city-fan.org> - 1.20-1
- Update to 1.20
  - Use Capture::Tiny instead of IPC::Run3 (GH#4, GH#15)
  - Use Test2::V0 instead of Test2::Bundle::Extended for Test2 tests
  - Add support for stdin option that was lost in the Capture::Tiny migration
  - Minor documentation fixes
  - Officially drop support for Perl 5.6 (support for 5.6 was already
    implicitly dropped when we migrated to Capture::Tiny)
  - A near term future version will also drop support for the old pre-Test2
    Test::Builder

* Wed Apr 12 2017 Paul Howarth <paul@city-fan.org> - 1.18-1
- Update to 1.18
  - Handle scripts with -T taint mode (GH#13)
  - Use three-argument open
- Drop support for EOL distributions prior to F-13
  - Drop BuildRoot: and Group: tags
  - Drop explicit buildroot cleaning in %%install section
  - Drop explicit %%clean section
  - Drop workaround for building with Test::More < 0.96

* Sun Mar  5 2017 Paul Howarth <paul@city-fan.org> - 1.16-1
- Update to 1.16
  - Stricter usage of plans

* Tue Feb 14 2017 Paul Howarth <paul@city-fan.org> - 1.15-1
- Update to 1.15
  - Fix bug where list reference arguments to script_compiles and script_runs
    are modified (GH#9)

* Thu Oct 13 2016 Paul Howarth <paul@city-fan.org> - 1.14-1
- Update to 1.14
  - Fix a regex in a test that fails on recent versions of Test2 on Windows
    (possibly others) (GH#8)
  - One of the tests was unreasonably slow, so it does not get run for users,
    and will be used for development only
  - Remove warning condition that happens with at least some older versions
    of Perl when using quotemeta without parentheses (GH#7)

* Thu Oct  6 2016 Paul Howarth <paul@city-fan.org> - 1.12-3
- BR: perl-generators where available

* Tue May  3 2016 Paul Howarth <paul@city-fan.org> - 1.12-1
- Update to 1.12
  - Including some optional Test2-based tests that should only be run with a
    merged Test2/Test::Builder (currently a dev release as Test::Simple on
    CPAN)
  - One possible fix for https://github.com/plicease/Test-Script/issues/5
  - Check for IO errors on temporary .pm file
- Add patch to silence 'Warning: Use of "quotemeta" without parentheses is
  ambiguous' warnings on older perls

* Mon Jun 22 2015 Paul Howarth <paul@city-fan.org> - 1.10-4
- Perl 5.22 rebuild

* Wed May 13 2015 Paul Howarth <paul@city-fan.org> - 1.10-1
- Update to 1.10
  - Workaround for buggy IPC::Run3 0.048 on MSWin32
    (https://github.com/plicease/Test-Script/issues/1)

* Fri May  8 2015 Paul Howarth <paul@city-fan.org> - 1.09-1
- Update to 1.09
  - If IPC::Run3::run3 throws an exception it will now fail the test (with a
    helpful diagnostic) rather than crashing the test script
  - A script that is killed with a signal is now considered a failure as well
  - Use alternate expected exit and signal values with options as the second
    argument to script_runs
  - Ability to pass input via stdin to the script with script_runs
  - Ability to capture stdout and stderr from script with script_runs
  - Functions to test stdout and stderr:
    - script_stdout_is
    - script_stdout_isnt
    - script_stdout_like
    - script_stdout_unlike
    - script_stderr_is
    - script_stderr_isnt
    - script_stderr_like
    - script_stderr_unlike
- Bundle Test-Simple 1.x for testing on old distributions that don't have a
  recent enough version

* Wed May  6 2015 Paul Howarth <paul@city-fan.org> - 1.08-1
- Update to 1.08
  - Now works with or without blib (CPAN RT#81222, CPAN RT#102743)
  - Compatibility with older versions of Test::Builder::Tester (CPAN RT#81335)
  - Requires Perl 5.6.0
  - Migrate to Dist::Zilla
- This release by PLICEASE → update source URL
- Classify buildreqs by usage
- Drop workaround for old Test::More versions

* Mon Sep  1 2014 Paul Howarth <paul@city-fan.org> - 1.07-17
- Drop %%defattr, redundant since rpm 4.4
- Use %%license where possible

* Mon Jul 16 2012 Paul Howarth <paul@city-fan.org> - 1.07-9
- Perl 5.16 post-bootstrap rebuild

* Mon Jul  2 2012 Paul Howarth <paul@city-fan.org> - 1.07-8
- BR: perl(Carp), perl(Cwd), perl(Exporter), perl(File::Path),
  perl(File::Spec), perl(File::Spec::Functions), perl(File::Spec::Unix) and
  perl(Test::Builder)
- Don't need to remove empty directories from the buildroot
- Drop support for old distributions prior to FC-3:
  - Don't need to define %%{perl_vendorlib}
  - Use DESTDIR rather than PERL_INSTALL_ROOT

* Thu Jun 30 2011 Paul Howarth <paul@city-fan.org> - 1.07-6
- Rebuild for perl 5.14.1 in Rawhide
- Use %%{_fixperms} macro instead of our own %%{__chmod} incantation
- Add support for perl_bootstrap macro
- Nobody else likes macros for commands
- Fix dist tag for CentOS 6 and Scientific Linux

* Thu Jun 24 2010 Paul Howarth <paul@city-fan.org> - 1.07-3
- Rebuild for perl 5.12.1 in Rawhide

* Fri May 28 2010 Paul Howarth <paul@city-fan.org> - 1.07-2
- Fix dist tag for RHEL-6 Beta

* Tue Nov 24 2009 Paul Howarth <paul@city-fan.org> - 1.07-1
- Update to 1.07 (second attempt at fixing the "Using" bug)
- Update patch for t/03_compiles_bad.t (also patches t/05_runs_bad.t now)
- Use search.cpan.org source URL
- Dist tag for Rawhide no longer needs special-casing

* Thu Sep 17 2009 Paul Howarth <paul@city-fan.org> - 1.06-1
- Update to 1.06 (fix t/03_compiles_bad.t)
- Update patch for t/03_compiles_bad.t (upstream fix requires
  Test::More >= 0.77)
- Manually add perl(Test::More) runtime dependency

* Tue Sep 15 2009 Paul Howarth <paul@city-fan.org> - 1.05-1
- Update to 1.05
  - change script_compiles_ok to script_compiles
  - add script_runs
  - attempt to support 5.6 properly
  - add dependency on Probe::Perl
  - full fidelity failure testing
  - update author tests
- Enable AUTOMATED_TESTING
- Buildreq Test::CPAN::Meta, Perl::MinimumVersion, Pod::Simple, Test::Pod, and
  Test::MinimumVersion
- Define RPM macros in global scope
- Patch t/03_compiles_bad.t to fix test failure when necessary

* Mon Sep  1 2008 Paul Howarth <paul@city-fan.org> - 1.03-2
- Import from Fedora

* Tue Mar 11 2008 Ralf Corsépius <rc040203@freenet.de> - 1.03-1
- Upstream update.

* Wed Feb 27 2008 Tom "spot" Callaway <tcallawa@redhat.com> - 1.02-4
- Rebuild for perl 5.10 (again)

* Sat Jan 12 2008 Tom "spot" Callaway <tcallawa@redhat.com> - 1.02-3
- Rebuild for new perl

* Tue Sep 18 2007 Ralf Corsépius <rc040203@freenet.de> - 1.02-2
- Reflect license tag changes.
- BR: perl(Test::More).
- Remove BR: perl.
- Add chmod -x Changes lib/Test/*pm

* Tue Aug 07 2007 Ralf Corsépius <rc040203@freenet.de> - 1.02-1
- Specfile autogenerated by cpanspec 1.73.