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

Update.ci+fixes #14

Merged
merged 6 commits into from
Feb 25, 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
53 changes: 0 additions & 53 deletions .appveyor.cmd

This file was deleted.

180 changes: 164 additions & 16 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,173 @@
---
clone_folder: C:\projects\perl-text-template
# .appveyor.yml (for Perl distributions)

cache:
- C:\strawberry
- C:\cygwin
# * (APIv1) for usage instructions, see <https://github.com/rivy/CI.AppVeyor.helpers-perl/blob/stable.APIv1/README.mkd>

# ref: <https://www.appveyor.com/docs/appveyor-yml>[`@`](https://archive.is/OUJHS)
# * "appveyor.yml" validation tool @ <https://ci.appveyor.com/tools/validate-yaml>

version: "{build} ~ {branch}"

branches:
except:
- gh-pages

skip_tags: true ## do not build on tags

matrix:
allow_failures:
- AUTHOR_TESTING: 1
- TEST_SIGNATURE: 1
- CI_HELPER_BRANCH: canary
- Perl_VERSION: "5.8.8" ## allow perl v5.8.8 failures; (v5.8.8 is problematic for many projects)

environment:
matrix:
- perl_type: cygwin
- perl_type: strawberry
- Perl_VERSION: "latest"
COVERAGE: "Codecov Coveralls" ## note: case sensitive!
AUTHOR_TESTING: 1
RELEASE_TESTING: 1
- Perl_VERSION: "5.28"
- Perl_VERSION: "5.26"
- Perl_VERSION: "5.24"
- Perl_VERSION: "5.22"
- Perl_VERSION: "5.20"
- Perl_VERSION: "5.16"
- Perl_VERSION: "5.14"
- Perl_VERSION: "5.12"
- Perl_VERSION: "5.10"
- Perl_VERSION: "5.8.9"
- Perl_VERSION: "5.8.8"
- Perl_VERSION: "latest"
CI_HELPER_BRANCH: "canary"
TEST_SIGNATURE: 1
global:
AUTOMATED_TESTING: 1
CI_CACHE_DIR: "C:\\cache"
#
# debug?
# CI_DEBUG: 1 ## [ "" == false, <non-empty> == true ]; "true" enables detailed output for the helper scripts
#
## configuration (CI/network-side settings and then ".appveyor_init.{BAT,PS1}" [if present], may override these values [by design])
## ---
# * standard perl distribution test configuration signals
AUTHOR_TESTING: ""
RELEASE_TESTING: ""
# * .appveyor.yml configuration variables
CI_HELPER_API_VERSION: "1" ## * API version (the expected/requested helper API version)
CI_HELPER_BRANCH: "" ## "" => auto-set, valid alternates are [ "stable" (the default), "canary", BRANCH, or TAG ]
CI_HELPER_REPO: "" ## "" => auto-set; allows easier use of alternate helper scripts (ie, alternate forks)
DEVEL_COVER_OPTIONS: "" ## "" => auto-set, value determined by DIST_TOOLING; quoted whitespace (eg, " ") is an empty/neutral setting which also blocks auto-set
DIST_EXTRA_DEPS: "" ## additional required/requested dependencies for build and/or testing
DIST_SUPPRESS_DEPS: "" ## [ "" == false, <non-empty> == true ]; "true" can be useful for CORE modules, suppressing discovery and installation of dependencies, unless otherwise required (by COVERAGE or DIST_EXTRA_DEPS)
DIST_TOOLING: "" ## [ "build", "make" ]; "" => auto-set based on existence of "Build.PL" and/or "Makefile.PL"
TEST_METHOD: "" ## "" => auto-set based on DIST_TOOLING (`perl Build test`, `%make% test`, or `prove -bl`)
TEST_FILES: "" ## "" => auto-set to "" for build/make distributions, otherwise "t" or "t xt" depending on AUTHOR_TESTING and/or RELEASE_TESTING and directory existence
## ---

cache:
# note: unused, because, unfortunately, the available cache is too small to be helpful (unshared; 1GB across all projects)
# - '%CI_CACHE_DIR% -> .appveyor.yml'

install:
- 'call .appveyor.cmd perl_setup'
- '%perl% -V'
- '%cpanm% --quiet --notest --skip-satisfied Dist::Zilla Test::Pod'
- '%dzil% authordeps --missing | %cpanm% --quiet --notest'
- '%dzil% listdeps --missing | %cpanm% --verbose'
- git config --global user.name "AppVeyor"
- git config --global user.email "appveyor-not-for-mail@appveyor.com"
- ps: ; write-host $("[{0:HH:mm:ss}].install" -f $($mark = get-date; $mark)) -f darkgray
# ensure CWD is project main directory
- cd "%APPVEYOR_BUILD_FOLDER%"
# perform any special preparation (optional; distribution specific)
# * note: optional external file(s), global scope => allows ".appveyor.yml" to remain more stable and similar [or the same] between different distributions [eg, for automated distribution of ".appveyor.yml" changes]
- if EXIST ".appveyor_init.BAT" ( call .appveyor_init.BAT )
- ps: if ( test-path ".appveyor_init.PS1" ) { . ".\.appveyor_init.PS1" }
# save current-point-in-time environment (for later logging of environment variable overrides)
- ps: $baseline_env = @(get-childitem env:)
# create a working area
- ps: if ( ! $env:CI_TEMP_DIR ) { $env:CI_TEMP_DIR = "${env:TEMP}\${env:APPVEYOR_JOB_ID}" ; mkdir -force $env:CI_TEMP_DIR | out-null }
# create cache area, if missing
- if NOT DEFINED CI_CACHE_DIR ( set "CI_CACHE_DIR=%CI_TEMP_DIR%\cache" )
- if NOT EXIST "%CI_CACHE_DIR%" ( mkdir "%CI_CACHE_DIR%" )
# finalize HELPER repository location
- if NOT DEFINED CI_HELPER_API_VERSION ( set "CI_HELPER_API_VERSION=1" )
- if NOT DEFINED CI_HELPER_REPO ( set "CI_HELPER_REPO=https://github.com/rivy/CI.AppVeyor.helpers-perl.git" )
- if NOT DEFINED CI_HELPER_BRANCH ( set "CI_HELPER_BRANCH=stable" )
- if /i "%CI_HELPER_BRANCH%"=="canary" ( set "CI_HELPER_BRANCH=canary.APIv%CI_HELPER_API_VERSION%" )
- if /i "%CI_HELPER_BRANCH%"=="stable" ( set "CI_HELPER_BRANCH=stable.APIv%CI_HELPER_API_VERSION%" )
# find / download helpers
- ps: ; write-host $("[{0:HH:mm:ss}].install (helpers)" -f $($mark_sub = get-date; $mark_sub)) -f darkgray
# * use "vendored" copy if present
- ps: if ( ! $env:CI_HELPERS -and (test-path ".appveyor_bin") ) { $env:CI_HELPERS=[IO.Path]::GetFullPath(".appveyor_bin") ; ${env:CI_HELPER_REPO} = ${env:APPVEYOR_REPO_NAME} ; ${env:CI_HELPER_BRANCH_DESC} = ${env:APPVEYOR_REPO_COMMIT} ; }
# * clone/download helpers from HELPER repo (via `git`) if needed
- ps: if ( ! $env:CI_HELPERS ) { $repo_path = $( mkdir "${env:CI_TEMP_DIR}\helpers" ).Fullname ; $git_cmd = "git clone ${env:CI_HELPER_REPO} `"${repo_path}`" -b ${env:CI_HELPER_BRANCH} 2>&1" ; write-host "[``${git_cmd}``]" ; & 'CMD' @( '/c', $git_cmd ) ; $err = $LASTEXITCODE ; $env:CI_HELPERS = "${repo_path}\.appveyor_bin" ; if ($err -ne 0) { exit $err } ; }
- ps: if ( ! $env:CI_HELPER_BRANCH_DESC ) { ${env:CI_HELPER_BRANCH_DESC} = $( pushd "${env:CI_HELPERS}" ; & 'git' @( 'describe', '--always' ) 2>&1 ; popd ) ; }
- ps: ; write-host $("[{0:HH:mm:ss}].install (helpers) ... (${env:CI_HELPER_REPO}@${env:CI_HELPER_BRANCH_DESC})")
# resolve requested coverage with needed configuration
- ps: . "${env:CI_HELPERS}\#install.determine-coverage.PS1"
##
# highlight any overrides within baseline environment
- ps: $baseline_env | & "${env:CI_HELPERS}\log.env-overrides.PS1"
##
# move "C:\mingw" to avoid cross library linking (a problem with older perl versions, breaking dll compilation with "/mingw/lib/dllcrt2.o:(.text+0xd1): undefined reference to `__dyn_tls_init_callback'")
# * only truly needed for modules containing XS compilation, but ok for all modules
- move c:\mingw c:\mingw.o >NUL
# force branch checkout (if knowable), then reset to the specific commit ## (needed for accurate code coverage info)
# * this allows later apps to see the branch name using standard `git branch` operations, yet always builds the correct specific commit
# * ref: <https://github.com/appveyor/ci/issues/1606>[`@`](https://archive.is/RVpnF)
- if DEFINED APPVEYOR_REPO_BRANCH if /i "%APPVEYOR_REPO_SCM%"=="git" ( git checkout "%APPVEYOR_REPO_BRANCH%" >NUL & git reset --hard "%APPVEYOR_REPO_COMMIT%" )
# install perl (strawberry variant) + version verification
- ps: ; write-host $("[{0:HH:mm:ss}].install (perl)" -f $($mark_sub = get-date; $mark_sub)) -f darkgray
- ps: . "${env:CI_HELPERS}\#install.install-perl.PS1"
- perl -V
- ps: ; write-host $("[{0:HH:mm:ss}].install (perl) ... done ({1:0.0}s)" -f $(get-date; $($(get-date) - $mark_sub).totalseconds)) -f gray
# determine build tooling
- ps: . "${env:CI_HELPERS}\#install.determine-tooling.PS1"
# setup DEVEL_COVER_OPTIONS, if needed
- ps: if (! $env:DEVEL_COVER_OPTIONS) { . "${env:CI_HELPERS}\#install.setup-cover_options.PS1" }
# setup testing method/options and test files
- ps: . "${env:CI_HELPERS}\#install.setup-testing.PS1"
# distribution prep prior to the build/make process (ie, build dependencies and OS_unsupported check)
- ps: ; write-host $("[{0:HH:mm:ss}].install (distribution requirements and recommendations)" -f $($mark_sub = get-date; $mark_sub)) -f darkgray
- ps: . "${env:CI_HELPERS}\#install.setup-dist.PS1"
- ps: ; write-host $("[{0:HH:mm:ss}].install (distribution requirements and recommendations) ... done ({1:0.0}s)" -f $(get-date; $($(get-date) - $mark_sub).totalseconds)) -f gray
# coverage prep
- ps: ; write-host $("[{0:HH:mm:ss}].install (coverage requirements)" -f $($mark_sub = get-date; $mark_sub)) -f darkgray
- ps: . "${env:CI_HELPERS}\#install.setup-coverage.PS1"
- ps: ; write-host $("[{0:HH:mm:ss}].install (coverage requirements) ... done ({1:0.0}s)" -f $(get-date; $($(get-date) - $mark_sub).totalseconds)) -f gray
#
- ps: ; write-host $("[{0:HH:mm:ss}].install ... done ({1:0.0}s)" -f $(get-date; $($(get-date) - $mark).totalseconds)) -f green

build: off
before_build:
- ps: ; write-host $("[{0:HH:mm:ss}].build.before_build" -f $($mark = get-date; $mark)) -f darkgray
# ensure CWD is project main directory
- cd "%APPVEYOR_BUILD_FOLDER%"
# * for non-COVERAGE builds, enable parallel processing (COVERAGE builds need sequential, correctly interleaved, output to avoid warnings)
- if NOT DEFINED COVERAGE (set "HARNESS_OPTIONS=j")
- set HARNESS_TIMER=1
# * for COVERAGE builds, enable coverage for `prove` testing
- if DEFINED COVERAGE (set HARNESS_PERL_SWITCHES=-MDevel::Cover %HARNESS_PERL_SWITCHES%)
# * for COVERAGE builds, preload JSON:PP to avoid JSON::PP::Boolean redefine warning (see <https://github.com/rurban/Cpanel-JSON-XS/issues/65#issuecomment-219352754>)
- if DEFINED COVERAGE (set HARNESS_PERL_SWITCHES=-MJSON::PP %HARNESS_PERL_SWITCHES%)
#
- ps: . "${env:CI_HELPERS}\#build-before_build.PS1"
# show final build-related environment variables
- ps: . "${env:CI_HELPERS}\log.env.PS1"
#
- ps: ; write-host $("[{0:HH:mm:ss}].build.before_build ... done ({1:0.0}s)" -f $(get-date; $($(get-date) - $mark).totalseconds)) -f green

build_script:
- ps: ; write-host $("[{0:HH:mm:ss}].build.build_script" -f $($mark = get-date; $mark)) -f darkgray
- ps: . "${env:CI_HELPERS}\#build-build_script.PS1"
- ps: ; write-host $("[{0:HH:mm:ss}].build.build_script ... done ({1:0.0}s)" -f $(get-date; $($(get-date) - $mark).totalseconds)) -f green

test_script:
- '%dzil% smoke --release --author'
- ps: ; write-host $("[{0:HH:mm:ss}].test.test_script" -f $($mark = get-date; $mark)) -f darkgray
- ps: . "${env:CI_HELPERS}\#test-test_script.PS1"
- ps: ; write-host $("[{0:HH:mm:ss}].test.test_script ... done ({1:0.0}s)" -f $(get-date; $($(get-date) - $mark).totalseconds)) -f green

after_test:
- ps: ; write-host $("[{0:HH:mm:ss}].test.after_test" -f $($mark = get-date; $mark)) -f darkgray
# reporting
# * report any code coverage information
- ps: if (-not $env:OS_unsupported -and $env:COVERAGE) { $env:COVERAGE.split() | foreach { & 'CMD' @( '/c', "cover -report $_ 2>&1" ) } }
- ps: ; write-host $("[{0:HH:mm:ss}].test.after_test ... done ({1:0.0}s)" -f $(get-date; $($(get-date) - $mark).totalseconds)) -f green
# end with any informational or warning messages, if needed
- ps: if ($env:CI_SKIP) { write-host -f magenta "info:` CI_SKIP enabled" ; Add-AppveyorMessage -Message "CI_SKIP enabled" -Category Info }
- ps: if ($env:CI_SKIP_TEST) { write-host -f magenta "info:` CI_SKIP_TEST enabled" ; Add-AppveyorMessage -Message "CI_SKIP_TEST enabled" -Category Info }
# * prominent "unsupported" warning
- ps: if ($env:OS_unsupported) { write-host -f magenta "WARN:` OS unsupported" ; Add-AppveyorMessage -Message "OS unsupported" -Category Warning }
10 changes: 10 additions & 0 deletions .appveyor_init.BAT
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
:: configuration
@prompt $g$s &:: minimize output "noise"
@echo ON

:: add extra testing dependencies
:: * Test::More v0.94+ needed for `done_testing` + extra non-CORE modules
set "DIST_EXTRA_DEPS=Test::More~0.94 Test::More::UTF8 Test::Warnings"

@echo OFF
@echo.
4 changes: 3 additions & 1 deletion t/nested-tags.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
use strict;
use warnings;
use Text::Template;
use Test::More;

# Minimum Test::More version; 0.94+ is required for `done_testing`
BEGIN { if (! eval { require Test::More; "$Test::More::VERSION" >= 0.94; } ) { use Test::More; plan skip_all => '[ Test::More v0.94+ ] is required for testing' } };

my $tmpl = Text::Template->new(
TYPE => 'STRING',
Expand Down
9 changes: 9 additions & 0 deletions t/safe2.t
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ is $text, 'package is safe root';

# (4) When a package is specified in safe mode, we should use the
# default safe root, after aliasing to the specified package
TODO: {
local $TODO = "test fails when tested with TAP/Devel::Cover" if defined $Devel::Cover::VERSION;
$text = $t->fill_in(SAFE => $c, PACKAGE => 'Q');
is $text, 'package is Q';
}

# Now let's see if hash vars are installed properly into safe templates
$t = Text::Template->new(
Expand All @@ -64,14 +67,20 @@ $text = $t->fill_in(HASH => { H => 'good6' }, PACKAGE => 'Q');
is $text, 'hash is good6';

# (7) Now in the default root of the safe compartment
TODO: {
local $TODO = "test fails when tested with TAP/Devel::Cover" if defined $Devel::Cover::VERSION;
$text = $t->fill_in(HASH => { H => 'good7' }, SAFE => $c);
is $text, 'hash is good7';
}

# (8) Now in the default root after aliasing to a package that
# got the hash stuffed in
our $H;
TODO: {
local $TODO = "test fails when tested with TAP/Devel::Cover" if defined $Devel::Cover::VERSION;
$text = $t->fill_in(HASH => { H => 'good8' }, SAFE => $c, PACKAGE => 'Q2');
is $text, 'hash is good8';
}

# Now let's make sure that none of the packages leaked on each other.
# (9) This var should NOT have been installed into the main package
Expand Down
10 changes: 9 additions & 1 deletion t/taint.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ use File::Temp;

use_ok 'Text::Template' or exit 1;

my $tmpfile = File::Temp->new( $^O eq 'MSWin32' ? (DIR => '.') : () );
if ($^O eq 'MSWin32') {
# File::Temp (for all versions up to at least 0.2308) is currently bugged under MSWin32/taint mode [as of 2018-09]
# ... fails unless "/tmp" on the current windows drive is a writable directory OR either $ENV{TMP} or $ENV{TEMP} are untainted and point to a writable directory
# ref: [File-Temp: Fails under -T, Windows 7, Strawberry Perl 5.12.1](https://rt.cpan.org/Public/Bug/Display.html?id=60340)
( $ENV{TEMP} ) = $ENV{TEMP} =~ m/^.*$/gmsx; # untaint $ENV{TEMP}
( $ENV{TMP} ) = $ENV{TMP} =~ m/^.*$/gmsx; # untaint $ENV{TMP}
}

my $tmpfile = File::Temp->new;
my $file = $tmpfile->filename;

# makes its arguments tainted
Expand Down
8 changes: 6 additions & 2 deletions t/template-encoding.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
use utf8;
use strict;
use warnings;
use Test::More tests => 3;
use Test::More;
use Encode;
use File::Temp;
use Test::More::UTF8;

# Non-CORE module(s)
if (! eval { require Test::More::UTF8; 1; } ) { plan skip_all => '[ Test::More::UTF8 ] is required for testing' };

plan tests => 3;

use_ok 'Text::Template' or exit 1;

Expand Down
9 changes: 7 additions & 2 deletions t/warnings.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

use strict;
use warnings;
use Test::More;
use Test::Warnings;

# Minimum Test::More version; 0.94+ is required for `done_testing`
BEGIN { if (! eval { require Test::More; "$Test::More::VERSION" >= 0.94; } ) { use Test::More; plan skip_all => '[ Test::More v0.94+ ] is required for testing' } };

# Non-CORE module(s)
if (! eval { require Test::Warnings; 1; } ) { plan skip_all => '[ Test::Warnings ] is required for testing' };

use Text::Template;

my $template = <<'EOT';
Expand Down