diff options
| author | Ailin Nemui | 2015-01-27 22:07:16 +0100 | 
|---|---|---|
| committer | Ailin Nemui | 2015-01-28 01:56:17 +0100 | 
| commit | 5996cf5285d66ae8a1ff3ad8a88651753988a4b9 (patch) | |
| tree | 09bdcfffabb79cce63cd0435875943c88e5bdc9f /_testing | |
| parent | ee28c80cba8f2ad3df17b54ecc22764d59391b9b (diff) | |
| download | scripts.irssi.org-5996cf5285d66ae8a1ff3ad8a88651753988a4b9.tar.bz2 | |
Correctly preserve non-numeric version numbers
The YAML module that available in the Travis repos does not enforce
marking of numeric-looking variables as strings. When these are parsed
by the github site generator, precision is lost as they are interpreted
numerically (eg. version: 1.10 -> turns into 1.1).
Reported by Vilkku. Fixes #125
Diffstat (limited to '_testing')
| -rw-r--r-- | _testing/_irssi_test.pl | 21 | ||||
| -rw-r--r-- | _testing/travis/update-scripts-yaml.pl | 31 | 
2 files changed, 26 insertions, 26 deletions
| diff --git a/_testing/_irssi_test.pl b/_testing/_irssi_test.pl index 1da8f59..bcfcb3c 100644 --- a/_testing/_irssi_test.pl +++ b/_testing/_irssi_test.pl @@ -18,6 +18,21 @@ Irssi::command('^window log off');  my ($package) = grep { !/^_/ } keys %Irssi::Script::;  require YAML::Tiny; +YAML::Tiny->VERSION("1.59"); +require Encode; +{ +    # This is an ugly hack to be `lax' about the encoding. We try to +    # read everything as UTF-8 regardless of declared file encoding +    # and fall back to Latin-1. +    my $orig = YAML::Tiny->can("_has_internal_string_value"); +    *YAML::Tiny::_has_internal_string_value = sub { +	my $ret = $orig->(@_); +	use bytes; +	$_[0] = Encode::decode_utf8($_[0], sub{pack 'U', +shift}) +	    unless Encode::is_utf8($_[0]); +	$ret +    } +}  require Module::CoreList;  require CPAN::Meta::Requirements;  require Perl::PrereqScanner; @@ -32,8 +47,7 @@ my (%info, $version);  unless (defined $package) {      my %fail = (failed => 1, name => $CURRENT_SCRIPT);      $fail{modules} = \@modules if @modules; -    { open my $ef, '>:utf8', "failed.yml"; -      print $ef YAML::Tiny::Dump([\%fail]); } +    YAML::Tiny::DumpFile("failed.yml", [\%fail]);      # Grep for the code instead      require PPI;      require PPIx::XPath; @@ -74,5 +88,4 @@ if ($loginfo) {  }  $info{modules} = \@modules if @modules;  $info{default_package} = $package =~ s/::$//r if $package; -{ open my $ef, '>:utf8', "info.yml"; -  print $ef YAML::Tiny::Dump([\%info]); } +YAML::Tiny::DumpFile("info.yml", [\%info]); diff --git a/_testing/travis/update-scripts-yaml.pl b/_testing/travis/update-scripts-yaml.pl index 5762096..0ed52ac 100644 --- a/_testing/travis/update-scripts-yaml.pl +++ b/_testing/travis/update-scripts-yaml.pl @@ -1,19 +1,10 @@  use strict; use warnings; -use YAML::Tiny; -use Scalar::Util; -BEGIN { -    sub YAML::Tiny::_has_internal_string_value { -	!Scalar::Util::looks_like_number($_[0]) -    } -} +use YAML::Tiny 1.59; -my @config; -if (open my $ef, '<:utf8', '_testing/config.yml') { -    @config = Load(do { local $/; <$ef> }); -} +my $config = YAML::Tiny::LoadFile('_testing/config.yml');  my @yaml_keys; -if (@config) { -    @yaml_keys = @{ $config[0]{scripts_yaml_keys}//[] }; +if ($config) { +    @yaml_keys = @{ $config->{scripts_yaml_keys}//[] };  }  die "no keys defined in config.yaml\n" unless @yaml_keys; @@ -75,14 +66,12 @@ my @newdoc = map {          } sort @yaml_keys      }  } sort keys %newmeta; -{ open my $ef, '>:utf8', '_data/scripts.yaml' or die $!; -  print $ef Dump \@newdoc; -} +YAML::Tiny::DumpFile('_data/scripts.yaml', \@newdoc); -if (@config && @{$config[0]{whitelist}//[]}) { +if ($config && @{$config->{whitelist}//[]}) {      my $changed;      my @wl; -    for my $sf (@{$config[0]{whitelist}}) { +    for my $sf (@{$config->{whitelist}}) {  	if (-s "Test/$sf:passed") {  	    $changed = 1;  	} @@ -91,10 +80,8 @@ if (@config && @{$config[0]{whitelist}//[]}) {  	}      }      if ($changed) { -	$config[0]{whitelist} = \@wl; -	{ open my $ef, '>:utf8', '_testing/config.yml' or die $!; -	  print $ef Dump @config; -        } +	$config->{whitelist} = \@wl; +	YAML::Tiny::DumpFile('_testing/config.yml', $config);      }  } | 
