From c0ca5489e19881599531d761269c435c0698b532 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 12 Dec 2014 11:27:17 +0100 Subject: [PATCH] Don't use given/when These give warnings in Perl >= 5.18: given is experimental at /home/hydra/src/hydra/src/lib/Hydra/Helper/CatalystUtils.pm line 241. when is experimental at /home/hydra/src/hydra/src/lib/Hydra/Helper/CatalystUtils.pm line 242. ... --- src/lib/Hydra/Helper/AddBuilds.pm | 47 +++++++++++++-------------- src/lib/Hydra/Helper/CatalystUtils.pm | 15 ++++----- src/lib/Hydra/Plugin/CoverityScan.pm | 15 ++++----- src/script/hydra-evaluator | 1 - 4 files changed, 34 insertions(+), 44 deletions(-) diff --git a/src/lib/Hydra/Helper/AddBuilds.pm b/src/lib/Hydra/Helper/AddBuilds.pm index f4a16ab6..4eddacaa 100644 --- a/src/lib/Hydra/Helper/AddBuilds.pm +++ b/src/lib/Hydra/Helper/AddBuilds.pm @@ -1,7 +1,6 @@ package Hydra::Helper::AddBuilds; use strict; -use feature 'switch'; use utf8; use JSON; use IPC::Run; @@ -292,30 +291,28 @@ sub inputsToArgs { if scalar @{$inputInfo->{$input}} == 1 && defined $inputInfo->{$input}->[0]->{storePath}; foreach my $alt (@{$inputInfo->{$input}}) { - given ($alt->{type}) { - when ("string") { - push @res, "--argstr", $input, $alt->{value}; - } - when ("boolean") { - push @res, "--arg", $input, booleanToString($exprType, $alt->{value}); - } - when ("nix") { - die "input type ‘nix’ only supported for Nix-based jobsets\n" unless $exprType eq "nix"; - push @res, "--arg", $input, $alt->{value}; - } - when ("eval") { - die "input type ‘eval’ only supported for Nix-based jobsets\n" unless $exprType eq "nix"; - my $s = "{ "; - # FIXME: escape $_. But dots should not be escaped. - $s .= "$_ = builtins.storePath ${\$alt->{jobs}->{$_}}; " - foreach keys %{$alt->{jobs}}; - $s .= "}"; - push @res, "--arg", $input, $s; - } - default { - push @res, "--arg", $input, buildInputToString($exprType, $alt); - } - } + if ($alt->{type} eq "string") { + push @res, "--argstr", $input, $alt->{value}; + } + elsif ($alt->{type} eq "boolean") { + push @res, "--arg", $input, booleanToString($exprType, $alt->{value}); + } + elsif ($alt->{type} eq "nix") { + die "input type ‘nix’ only supported for Nix-based jobsets\n" unless $exprType eq "nix"; + push @res, "--arg", $input, $alt->{value}; + } + elsif ($alt->{type} eq "eval") { + die "input type ‘eval’ only supported for Nix-based jobsets\n" unless $exprType eq "nix"; + my $s = "{ "; + # FIXME: escape $_. But dots should not be escaped. + $s .= "$_ = builtins.storePath ${\$alt->{jobs}->{$_}}; " + foreach keys %{$alt->{jobs}}; + $s .= "}"; + push @res, "--arg", $input, $s; + } + else { + push @res, "--arg", $input, buildInputToString($exprType, $alt); + } } } diff --git a/src/lib/Hydra/Helper/CatalystUtils.pm b/src/lib/Hydra/Helper/CatalystUtils.pm index ab53beff..35e15927 100644 --- a/src/lib/Hydra/Helper/CatalystUtils.pm +++ b/src/lib/Hydra/Helper/CatalystUtils.pm @@ -6,7 +6,6 @@ use Exporter; use Readonly; use Nix::Store; use Hydra::Helper::Nix; -use feature qw/switch/; our @ISA = qw(Exporter); our @EXPORT = qw( @@ -238,15 +237,13 @@ sub showStatus { my ($build) = @_; my $status = "Failed"; - given ($build->buildstatus) { - when (0) { $status = "Success"; } - when (1) { $status = "Failed"; } - when (2) { $status = "Dependency failed"; } - when (4) { $status = "Cancelled"; } - when (6) { $status = "Failed with output"; } - } + if ($build->buildstatus == 0) { $status = "Success"; } + elsif ($build->buildstatus == 1) { $status = "Failed"; } + elsif ($build->buildstatus == 2) { $status = "Dependency failed"; } + elsif ($build->buildstatus == 4) { $status = "Cancelled"; } + elsif ($build->buildstatus == 6) { $status = "Failed with output"; } - return $status; + return $status; } diff --git a/src/lib/Hydra/Plugin/CoverityScan.pm b/src/lib/Hydra/Plugin/CoverityScan.pm index ca0c5dab..924111f4 100644 --- a/src/lib/Hydra/Plugin/CoverityScan.pm +++ b/src/lib/Hydra/Plugin/CoverityScan.pm @@ -1,7 +1,6 @@ package Hydra::Plugin::CoverityScan; use strict; -use feature 'switch'; use parent 'Hydra::Plugin'; use File::Basename; use LWP::UserAgent; @@ -63,14 +62,12 @@ sub buildFinished { my @exts = qw(.xz .bz2 .lzma .zip .tgz); my ($dir, $file, $ext) = fileparse($covTarball, @exts); my $mimetype; - given ($ext) { - when ('.xz') { $mimetype = "application/x-xz"; } - when ('.lzma') { $mimetype = "application/x-xz"; } - when ('.zip') { $mimetype = "application/zip"; } - when ('.bz2') { $mimetype = "application/x-bzip2"; } - when ('.tgz') { $mimetype = "application/x-gzip"; } - default { die "couldn't parse extension of $covTarball"; } - } + if ($ext eq '.xz') { $mimetype = "application/x-xz"; } + elsif ($ext eq '.lzma') { $mimetype = "application/x-xz"; } + elsif ($ext eq '.zip') { $mimetype = "application/zip"; } + elsif ($ext eq '.bz2') { $mimetype = "application/x-bzip2"; } + elsif ($ext eq '.tgz') { $mimetype = "application/x-gzip"; } + else { die "couldn't parse extension of $covTarball"; } die "couldn't detect mimetype of $covTarball" unless defined $mimetype; diff --git a/src/script/hydra-evaluator b/src/script/hydra-evaluator index 93912827..b9ef1c53 100755 --- a/src/script/hydra-evaluator +++ b/src/script/hydra-evaluator @@ -1,7 +1,6 @@ #! /var/run/current-system/sw/bin/perl -w use strict; -use feature 'switch'; use utf8; use Hydra::Schema; use Hydra::Plugin;