Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Devel-CheckOS CPAN distribution.

Report information
The Basics
Id: 63790
Status: resolved
Priority: 0/
Queue: Devel-CheckOS

People
Owner: Nobody in particular
Requestors: yanick+cpan [...] babyl.dyndns.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: add the possibility to require the OS not to be something
I'm attaching a patch that allows to use AssertOS to also be able to assert that the OS is not part of a set. Like so: use Devel::AssertOS qw/ -Amiga /; # anything but Amiga
Subject: 0001-add-the-possibility-to-require-the-OS-not-to-be-some.patch
From 3b4c8a96d230ef652620e0b6e23a40d9e11cd518 Mon Sep 17 00:00:00 2001 From: Yanick Champoux <yanick@babyl.dyndns.org> Date: Thu, 9 Dec 2010 20:54:22 -0500 Subject: [PATCH] add the possibility to require the OS not to be something --- lib/Devel/AssertOS.pm | 23 ++++++++++++++++++++++- t/12-assertos-single-invalid-OS.t | 3 ++- t/62-assertos-do-not-want.t | 12 ++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 t/62-assertos-do-not-want.t diff --git a/lib/Devel/AssertOS.pm b/lib/Devel/AssertOS.pm index 8e01778..b876445 100644 --- a/lib/Devel/AssertOS.pm +++ b/lib/Devel/AssertOS.pm @@ -28,12 +28,33 @@ do this: which will die unless the platform the code is running on is Linux, FreeBSD or Cygwin. +To assert that the OS is B<not> a specific platform, prepend the platform name +with a minus sign. For example, to run on anything but Amiga, do: + + use Devel::AssertOS qw(-Amiga); + + =cut sub import { shift; die("Devel::AssertOS needs at least one parameter\n") unless(@_); - Devel::CheckOS::die_if_os_isnt(@_); + + my @oses = @_; + + my ( @must, @must_not ); + + for my $os ( @oses ) { + if ( $os =~ s/^-// ) { + push @must_not, $os; + } + else { + push @must, $os; + } + } + + Devel::CheckOS::die_if_os_is(@must_not); + Devel::CheckOS::die_if_os_isnt(@must); } =head1 BUGS and FEEDBACK diff --git a/t/12-assertos-single-invalid-OS.t b/t/12-assertos-single-invalid-OS.t index ef9d885..f58f7e4 100644 --- a/t/12-assertos-single-invalid-OS.t +++ b/t/12-assertos-single-invalid-OS.t @@ -7,4 +7,5 @@ use lib File::Spec->catdir(qw(t lib)); use Test::More tests => 1; eval "use Devel::AssertOS 'NotAnOperatingSystem'"; -ok($@ =~ /OS unsupported/i); + +like $@, qr/OS unsupported/i; diff --git a/t/62-assertos-do-not-want.t b/t/62-assertos-do-not-want.t new file mode 100644 index 0000000..90be8af --- /dev/null +++ b/t/62-assertos-do-not-want.t @@ -0,0 +1,12 @@ +use strict; +$^W = 1; + +use File::Spec; +use lib File::Spec->catdir(qw(t lib)); + +use Test::More tests => 1; + +eval "use Devel::AssertOS qw/ -AnOperatingSystem /"; + +like $@ => qr/OS unsupported/; + -- 1.7.1
Thanks, patch applied. It'll hit the CPAN in version 1.7 soon. My apologies for the delay.