masak / bel

An interpreter for Bel, Paul Graham's Lisp language
GNU General Public License v3.0
27 stars 1 forks source link

t/00-consistent-fastfunc-exports.t fails on Windows #306

Closed masak closed 3 years ago

masak commented 3 years ago

Reason: CRLF newlines. The following patch fixes it:

diff --git a/t/00-consistent-fastfunc-exports.t b/t/00-consistent-fastfunc-exports.t
index ee1dfcd..829bc2a 100644
--- a/t/00-consistent-fastfunc-exports.t
+++ b/t/00-consistent-fastfunc-exports.t
@@ -15,6 +15,8 @@ my %exported_fastfuncs;
 my $interested = 0;

 while (my $line = <$fh>) {
+    $line =~ s/\r\n$//;
+
     if ($line =~ /^sub (fastfunc__\w+)\b/) {
         my $name = $1;
         $defined_fastfuncs{$name} = 1;

But we're now well into "this keeps happening" territory, and so I'd also like to look into a solution that abstracts away the handling of Windows line-break characters into the testing library, before closing this issue.

masak commented 3 years ago

Hah, after those changes, t/00-consistent-fastfuncs.t fails on Windows.

This diff seems to fix it, though:

diff --git a/lib/Language/Bel/Test.pm b/lib/Language/Bel/Test.pm
index 091fd59..31985f9 100644
--- a/lib/Language/Bel/Test.pm
+++ b/lib/Language/Bel/Test.pm
@@ -138,6 +138,7 @@ sub slurp_file {
     for_each_line_in_file($filename, sub {
         my ($line) = @_;
         push @lines, $line;
+        push @lines, "\n";
     });

     return join("", @lines);

Reopening.