Skip to content

This module fails to pass tests on Windows due to the use of OS specific hard-coded path separators in two of the Unit Tests #191

Description

@SteelBlueVision

The following two tests fail on Windows, because they make the erroneous assumption that the directory separator will always be a forward slash. Here is how to change the tests in order to no longer make this erroneous assumption:

Names of broken tests and diffs of a possible way to fix them:

t/000.2-warn.t:

--- t/000.2-warn.t      2024-01-17 12:20:41.000000000 -0600
+++ t/000.2-warn.t.correct      2024-03-10 13:39:15.285867300 -0500
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 use Test::More tests => 1;
-use Data::Printer::Common;
+use Data::Printer::Common; use File::Spec; my $dir_sep_char = File::Spec->catfile('', ''); # Piggybacked in order to retain hard-coded line nums in rest of script

 sub warnings(&) {
     my $code = shift;
@@ -15,4 +15,4 @@

 my $got = warnings { Data::Printer::Common::_warn(undef, "HA!") };

-is( $got, "[Data::Printer] HA! at t/000.2-warn.t line 16.\n", 'warn with proper caller/line' );
+is( $got, "[Data::Printer] HA! at t${dir_sep_char}000.2-warn.t line 16.\n", 'warn with proper caller/line' );

t/026-caller_message.t:

--- t/026-caller_message.t      2024-01-17 12:20:41.000000000 -0600
+++ t/026-caller_message.t.correct      2024-03-10 13:47:44.558267500 -0500
@@ -1,12 +1,12 @@
 use strict;
 use warnings;
-use Test::More tests => 2;
+use Test::More tests => 2; use File::Spec; my $dir_sep_char = File::Spec->catfile('', ''); # Piggybacked in order to retain hard-coded line nums in rest of script

 BEGIN {
     use Data::Printer::Config;
     no warnings 'redefine';
     *Data::Printer::Config::load_rc_file = sub { {} };
-};
+};

 use Data::Printer
     colored                 => 0,
@@ -19,13 +19,13 @@
 my $got = p $x;
 is(
     $got,
-    'Printing in line 19 of t/026-caller_message.t: undef',
+    "Printing in line 19 of t${dir_sep_char}026-caller_message.t: undef",
     'caller_info shows the proper caller message (after)'
 );

 $got = p $x, caller_message_position => 'after';
 is(
     $got,
-    'undef Printing in line 26 of t/026-caller_message.t:',
+    "undef Printing in line 26 of t${dir_sep_char}026-caller_message.t:",
     'caller_info shows the proper caller message (before)'
 );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions