From e7785745fa204a8375494c229f68811fcac20c4b Mon Sep 17 00:00:00 2001 From: David Cantrell Date: Wed, 1 May 2024 18:53:14 +0100 Subject: [PATCH] Get rid of deprecated functionality; Get rid of Ye Olde CVS noise; Add Mac OS 14 support --- CHANGELOG | 9 ++- MANIFEST | 1 + lib/Devel/AssertOS/DEC.pm | 2 - lib/Devel/AssertOS/Linux/v2_6.pm | 2 - lib/Devel/AssertOS/MacOSX/v10_4.pm | 2 - lib/Devel/AssertOS/MacOSX/v14.pm | 28 +++++++++ lib/Devel/AssertOS/MicrosoftWindows.pm | 2 - .../OSFeatures/POSIXShellRedirection.pm | 2 - lib/Devel/AssertOS/QNX.pm | 2 - lib/Devel/AssertOS/Realtime.pm | 2 - lib/Devel/AssertOS/Sun.pm | 2 - lib/Devel/CheckOS.pm | 59 ++++--------------- t/checkos.t | 15 +---- t/lib/Devel/AssertOS/AnOperatingSystem.pm | 2 - t/lib/Devel/AssertOS/AnOperatingSystem/v1.pm | 2 - t/lib/Devel/AssertOS/AnOperatingSystem/v2.pm | 2 - t/lib/Devel/AssertOS/NotAnOperatingSystem.pm | 2 - t/list_family_members.t | 19 ------ .../Devel/AssertOS/AnOperatingSystem.pm | 2 - t/pod.t | 1 - 20 files changed, 51 insertions(+), 107 deletions(-) create mode 100644 lib/Devel/AssertOS/MacOSX/v14.pm diff --git a/CHANGELOG b/CHANGELOG index eba3746..8c44007 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,13 @@ +2.00 XXXX-XX-XX + +- list_* no longer have special behaviour when called in scalar context. This has + been deprecated since version 1.90; + +- Add Devel::AssertOS::MacOSX::v14 (Sonoma) + 1.96 2023-02-04 -- Add Devel::AssertOS::MacOSX::v13 +- Add Devel::AssertOS::MacOSX::v13 (Ventura) - Add Devel::AssertOS::OSFeatures::Systemd diff --git a/MANIFEST b/MANIFEST index db9aca5..3567571 100644 --- a/MANIFEST +++ b/MANIFEST @@ -127,3 +127,4 @@ t/int-size.t lib/Devel/AssertOS/HWCapabilities/Int32.pm lib/Devel/AssertOS/MacOSX/v13.pm lib/Devel/AssertOS/OSFeatures/Systemd.pm +lib/Devel/AssertOS/MacOSX/v14.pm diff --git a/lib/Devel/AssertOS/DEC.pm b/lib/Devel/AssertOS/DEC.pm index 2871738..e5af54b 100644 --- a/lib/Devel/AssertOS/DEC.pm +++ b/lib/Devel/AssertOS/DEC.pm @@ -1,5 +1,3 @@ -# $Id: DEC.pm,v 1.5 2008/11/05 22:52:34 drhyde Exp $ - package Devel::AssertOS::DEC; use Devel::CheckOS; diff --git a/lib/Devel/AssertOS/Linux/v2_6.pm b/lib/Devel/AssertOS/Linux/v2_6.pm index f9026d0..da816b4 100644 --- a/lib/Devel/AssertOS/Linux/v2_6.pm +++ b/lib/Devel/AssertOS/Linux/v2_6.pm @@ -1,5 +1,3 @@ -# $Id: v2_6.pm,v 1.4 2008/11/05 22:52:35 drhyde Exp $ - package Devel::AssertOS::Linux::v2_6; use Devel::CheckOS; diff --git a/lib/Devel/AssertOS/MacOSX/v10_4.pm b/lib/Devel/AssertOS/MacOSX/v10_4.pm index dc2f8b7..ea74a90 100644 --- a/lib/Devel/AssertOS/MacOSX/v10_4.pm +++ b/lib/Devel/AssertOS/MacOSX/v10_4.pm @@ -1,5 +1,3 @@ -# $Id: v10_4.pm,v 1.4 2008/11/05 22:52:35 drhyde Exp $ - package Devel::AssertOS::MacOSX::v10_4; use Devel::CheckOS; diff --git a/lib/Devel/AssertOS/MacOSX/v14.pm b/lib/Devel/AssertOS/MacOSX/v14.pm new file mode 100644 index 0000000..8b27256 --- /dev/null +++ b/lib/Devel/AssertOS/MacOSX/v14.pm @@ -0,0 +1,28 @@ +package Devel::AssertOS::MacOSX::v14; + +use Devel::CheckOS; +use strict; +use warnings; +no warnings 'redefine'; + +our $VERSION = '1.0'; + +sub os_is { + Devel::CheckOS::os_is('MacOSX') && + `sw_vers -productVersion` =~ /^14/ ? 1 : 0; +} + +sub expn { "The operating system is some version of Mac OS Sonoma" } + +Devel::CheckOS::die_unsupported() unless(os_is()); + +=head1 COPYRIGHT and LICENCE + +Copyright 2023 David Cantrell + +This software is free-as-in-speech software, and may be used, distributed, and modified under the terms of either the GNU General Public Licence version 2 or the Artistic Licence. It's up to you which one you use. The full text of the licences can be found in the files GPL2.txt and ARTISTIC.txt, respectively. + +=cut + +1; + diff --git a/lib/Devel/AssertOS/MicrosoftWindows.pm b/lib/Devel/AssertOS/MicrosoftWindows.pm index e8ddd36..5bd678c 100644 --- a/lib/Devel/AssertOS/MicrosoftWindows.pm +++ b/lib/Devel/AssertOS/MicrosoftWindows.pm @@ -1,5 +1,3 @@ -# $Id: MicrosoftWindows.pm,v 1.6 2008/11/05 22:52:34 drhyde Exp $ - package Devel::AssertOS::MicrosoftWindows; use Devel::CheckOS; diff --git a/lib/Devel/AssertOS/OSFeatures/POSIXShellRedirection.pm b/lib/Devel/AssertOS/OSFeatures/POSIXShellRedirection.pm index 0f80ca2..9adac50 100644 --- a/lib/Devel/AssertOS/OSFeatures/POSIXShellRedirection.pm +++ b/lib/Devel/AssertOS/OSFeatures/POSIXShellRedirection.pm @@ -1,5 +1,3 @@ -# $Id: POSIXShellRedirection.pm,v 1.3 2008/11/05 22:52:35 drhyde Exp $ - package Devel::AssertOS::OSFeatures::POSIXShellRedirection; our $VERSION = '1.4'; diff --git a/lib/Devel/AssertOS/QNX.pm b/lib/Devel/AssertOS/QNX.pm index 8578d33..af2e933 100644 --- a/lib/Devel/AssertOS/QNX.pm +++ b/lib/Devel/AssertOS/QNX.pm @@ -1,5 +1,3 @@ -# $Id: QNX.pm,v 1.2 2008/10/27 20:31:21 drhyde Exp $ - package Devel::AssertOS::QNX; use Devel::CheckOS; diff --git a/lib/Devel/AssertOS/Realtime.pm b/lib/Devel/AssertOS/Realtime.pm index 623b174..16fed87 100644 --- a/lib/Devel/AssertOS/Realtime.pm +++ b/lib/Devel/AssertOS/Realtime.pm @@ -1,5 +1,3 @@ -# $Id: Realtime.pm,v 1.3 2008/11/05 22:52:34 drhyde Exp $ - package Devel::AssertOS::Realtime; use Devel::CheckOS; diff --git a/lib/Devel/AssertOS/Sun.pm b/lib/Devel/AssertOS/Sun.pm index f07bbf6..9185876 100644 --- a/lib/Devel/AssertOS/Sun.pm +++ b/lib/Devel/AssertOS/Sun.pm @@ -1,5 +1,3 @@ -# $Id: Sun.pm,v 1.5 2008/11/05 22:52:34 drhyde Exp $ - package Devel::AssertOS::Sun; use Devel::CheckOS; diff --git a/lib/Devel/CheckOS.pm b/lib/Devel/CheckOS.pm index c4fcdcb..68ab8dc 100644 --- a/lib/Devel/CheckOS.pm +++ b/lib/Devel/CheckOS.pm @@ -10,7 +10,7 @@ use File::Spec; use vars qw(@ISA @EXPORT_OK %EXPORT_TAGS %OS_ALIASES); -our $VERSION = '1.96'; +our $VERSION = '2.00'; @ISA = qw(Exporter); @EXPORT_OK = qw( @@ -196,18 +196,13 @@ sub die_unsupported { die("OS unsupported\n"); } =head3 list_platforms -When called in list context, -return a list of all the platforms for which the corresponding +Return a list of all the platforms for which the corresponding Devel::AssertOS::* module is available. This includes both OSes and OS families, and both those bundled with this module and any third-party add-ons you have installed. -In scalar context, returns a hashref keyed by platform with the filename -of the most recent version of the supporting module that is available to you. -This behaviour is deprecated. - -Unfortunately, on some platforms this list may have file case -broken. eg, some platforms might return 'freebsd' instead of 'FreeBSD'. +Unfortunately, on some platforms this list may have platform names' +case broken, eg you might see 'freebsd' instead of 'FreeBSD'. This is because they have case-insensitive filesystems so things should Just Work anyway. @@ -221,13 +216,8 @@ my $re_AssertOS = qr/$case_flag ^AssertOS$/x; my $re_Alias = qr/$case_flag ^Alias\b/x; sub list_platforms { - # sort by mtime, so oldest last. This was necessary so that if a module - # appears twice in @INC we pick the newer one but that functionality is - # no longer needed. We do need to de-dupe the list though - my @modules = sort { - (stat($a->{file}))[9] <=> (stat($b->{file}))[9] - } grep { - $_->{module} !~ $re_Alias + my @modules = sort keys %{ {map { $_ => 1 } grep { + $_ !~ $re_Alias } map { my (undef, $dir_part, $file_part) = File::Spec->splitpath($_); $file_part =~ s/\.pm$//; @@ -240,32 +230,19 @@ sub list_platforms { splice @dirs, 0, $i + 1; last; } - { - module => join('::', @dirs, $file_part), - file => File::Spec->canonpath($_) - } + join('::', @dirs, $file_part); } _find_pm_files_in_dirs( grep { -d } map { File::Spec->catdir($_, qw(Devel AssertOS)) } @INC - ); + )}}; - my %modules = map { - $_->{module} => $_->{file} - } @modules; - - if(wantarray()) { - return sort keys %modules; - } else { - warn("Calling list_platforms in scalar context and getting back a reference is deprecated and will go away some time after April 2024. To disable this warning set \$Devel::CheckOS::NoDeprecationWarnings::Context to a true value.\n") unless($Devel::CheckOS::NoDeprecationWarnings::Context); - return \%modules; - } + return @modules; } =head3 list_family_members Takes the name of an OS 'family' and returns a list of all its members. -In list context, you get a list, in scalar context you get an arrayref. If called on something that isn't a family, you get an empty list (or a ref to an empty array). @@ -279,16 +256,10 @@ sub list_family_members { # this will die if it's the wrong OS, but the module is loaded ... eval qq{use Devel::AssertOS::$family}; # ... so we can now query it - my @members = eval qq{ + return eval qq{ no strict 'refs'; &{"Devel::AssertOS::${family}::matches"}() }; - if(wantarray()) { - return @members; - } else { - warn("Calling list_family_members in scalar context and getting back a reference is deprecated and will go away some time after April 2024. To disable this warning set \$Devel::CheckOS::NoDeprecationWarnings::Context to a true value.\n") unless($Devel::CheckOS::NoDeprecationWarnings::Context); - return \@members; - } } =head3 register_alias @@ -354,13 +325,9 @@ open source endeavours by buying me something from my wishlist: Version 1.90 made all matches case-insensitive. This is a change in behaviour, but if it breaks your code then your code was already broken, you just didn't know it. -=head1 DEPRECATIONS - -At some point after April 2024 the C and C -functions will stop being sensitive to whether they are called in list context or -not, and will always return a list. From now until then calling them in non-list -context will emit a warning. You can turn that off by setting -C<$Devel::CheckOS::NoDeprecationWarnings::Context> to a true value. +As of version 2.00 the list_* functions always return plain old lists. Calling them +in scalar context was deprecated and has emitted warnings for over 2 years, since +version 1.90. =head1 SEE ALSO diff --git a/t/checkos.t b/t/checkos.t index d92b91f..874b6c8 100644 --- a/t/checkos.t +++ b/t/checkos.t @@ -42,21 +42,8 @@ ok(!(grep { /^Alias::MacOS$/i } Devel::CheckOS::list_platforms()), "list_platforms excludes Aliases"); eval "use lib File::Spec->catdir(qw(t otherlib))"; -sleep(2); -utime time(), time(), File::Spec->catfile(qw(t otherlib Devel AssertOS AnOperatingSystem.pm)); -ok(1 == (grep { /^AnOperatingSystem$/i } Devel::CheckOS::list_platforms()), +is(1, (grep { /^AnOperatingSystem$/i } Devel::CheckOS::list_platforms()), "A platform is listed only once"); -{ - local $Devel::CheckOS::NoDeprecationWarnings::Context = 1; - ok(Devel::CheckOS::list_platforms->{AnOperatingSystem} eq - File::Spec->catfile(qw(t otherlib Devel AssertOS AnOperatingSystem.pm)), - "scalar list_platforms gives the most recent module for an OS"); -} - -is - warning { my $foo = Devel::CheckOS::list_platforms() }, - "Calling list_platforms in scalar context and getting back a reference is deprecated and will go away some time after April 2024. To disable this warning set \$Devel::CheckOS::NoDeprecationWarnings::Context to a true value.\n", - "list_platforms in scalar context == warning"; done_testing; diff --git a/t/lib/Devel/AssertOS/AnOperatingSystem.pm b/t/lib/Devel/AssertOS/AnOperatingSystem.pm index 695aa15..fd21f2f 100644 --- a/t/lib/Devel/AssertOS/AnOperatingSystem.pm +++ b/t/lib/Devel/AssertOS/AnOperatingSystem.pm @@ -1,5 +1,3 @@ -# $Id: AnOperatingSystem.pm,v 1.1 2007/09/30 13:49:17 drhyde Exp $ - package Devel::AssertOS::AnOperatingSystem; use Devel::CheckOS qw(die_unsupported); diff --git a/t/lib/Devel/AssertOS/AnOperatingSystem/v1.pm b/t/lib/Devel/AssertOS/AnOperatingSystem/v1.pm index 530a95b..d297fd9 100644 --- a/t/lib/Devel/AssertOS/AnOperatingSystem/v1.pm +++ b/t/lib/Devel/AssertOS/AnOperatingSystem/v1.pm @@ -1,5 +1,3 @@ -# $Id: v1.pm,v 1.2 2007/10/18 13:31:25 drhyde Exp $ - package Devel::AssertOS::AnOperatingSystem::v1; use Devel::CheckOS qw(die_unsupported); diff --git a/t/lib/Devel/AssertOS/AnOperatingSystem/v2.pm b/t/lib/Devel/AssertOS/AnOperatingSystem/v2.pm index 38113e7..a9034cc 100644 --- a/t/lib/Devel/AssertOS/AnOperatingSystem/v2.pm +++ b/t/lib/Devel/AssertOS/AnOperatingSystem/v2.pm @@ -1,5 +1,3 @@ -# $Id: v2.pm,v 1.1 2007/10/18 13:29:34 drhyde Exp $ - package Devel::AssertOS::AnOperatingSystem::v2; use Devel::CheckOS qw(die_unsupported); diff --git a/t/lib/Devel/AssertOS/NotAnOperatingSystem.pm b/t/lib/Devel/AssertOS/NotAnOperatingSystem.pm index 93787cb..fbe6f33 100644 --- a/t/lib/Devel/AssertOS/NotAnOperatingSystem.pm +++ b/t/lib/Devel/AssertOS/NotAnOperatingSystem.pm @@ -1,5 +1,3 @@ -# $Id: NotAnOperatingSystem.pm,v 1.1 2007/09/30 13:49:17 drhyde Exp $ - package Devel::AssertOS::NotAnOperatingSystem; use Devel::CheckOS qw(die_unsupported); diff --git a/t/list_family_members.t b/t/list_family_members.t index 921e2f0..54b3649 100644 --- a/t/list_family_members.t +++ b/t/list_family_members.t @@ -26,23 +26,4 @@ is_deeply( 'array list_family_members works for DEC family' ); -{ - local $Devel::CheckOS::NoDeprecationWarnings::Context = 1; - is_deeply( - scalar(Devel::CheckOS::list_family_members('DEC')), - [qw(OSF VMS)], - 'scalar list_family_members works for DEC family' - ); - is_deeply( - scalar(Devel::CheckOS::list_family_members('MicrosoftWindows')), - [qw(Cygwin MSWin32 MSYS)], - 'scalar list_family_members works for MicrosoftWindows family' - ); -} - -is - warning { my $foo = Devel::CheckOS::list_family_members('MicrosoftWindows') }, - "Calling list_family_members in scalar context and getting back a reference is deprecated and will go away some time after April 2024. To disable this warning set \$Devel::CheckOS::NoDeprecationWarnings::Context to a true value.\n", - "list_platforms in scalar context == warning"; - done_testing; diff --git a/t/otherlib/Devel/AssertOS/AnOperatingSystem.pm b/t/otherlib/Devel/AssertOS/AnOperatingSystem.pm index 52665e1..fd21f2f 100644 --- a/t/otherlib/Devel/AssertOS/AnOperatingSystem.pm +++ b/t/otherlib/Devel/AssertOS/AnOperatingSystem.pm @@ -1,5 +1,3 @@ -# $Id: AnOperatingSystem.pm,v 1.1 2008/05/29 21:55:46 drhyde Exp $ - package Devel::AssertOS::AnOperatingSystem; use Devel::CheckOS qw(die_unsupported); diff --git a/t/pod.t b/t/pod.t index 9db8f76..e1a1cd7 100644 --- a/t/pod.t +++ b/t/pod.t @@ -1,4 +1,3 @@ -# $Id: pod.t,v 1.1 2008/06/16 15:01:29 drhyde Exp $ use strict; $^W=1;