@@ -20,7 +20,11 @@ sub new {
20
20
my $boundary = $1 ;
21
21
while ($data =~ s / ^$boundary[ \f\t ]*// s ) {
22
22
if ($data =~ s / ^([^\r\n ]+)\r ?\n (.*?)(?=$boundary|\z )// s ) {
23
- $hrx -> {main::catfile($1 )} = $2 ;
23
+ my $fname = main::catfile($1 );
24
+ if (exists $hrx -> {$fname }) {
25
+ warn " Overwriting " , $path , " => " , $fname , " \n " ;
26
+ }
27
+ $hrx -> {$fname } = $2 ;
24
28
}
25
29
elsif ($data =~ s / ^\r ?\n (.*?)(?=$boundary|\z )// s ) {}
26
30
else { die " No HRX file block found\n " ; }
@@ -77,7 +81,9 @@ package SPEC;
77
81
78
82
use CSS::Sass;
79
83
use Cwd qw( getcwd) ;
84
+ use Cwd qw( abs_path) ;
80
85
use Carp qw( croak) ;
86
+ use File::Basename;
81
87
use File::Spec::Functions;
82
88
83
89
my $cwd = getcwd;
@@ -102,7 +108,9 @@ my $norm_output = sub ($) {
102
108
$_ [0] =~ s /\Q $cwd_win\E [\/\\ ]t[\/\\ ]sass-spec[\/\\ ]/ \/ sass\/ / g ;
103
109
$_ [0] =~ s /\Q $cwd_nix\E [\/\\ ]t[\/\\ ]sass-spec[\/\\ ]/ \/ sass\/ / g ;
104
110
# normalize nth-child binomial whitespace
105
- $_ [0] =~ s /\(\s *(\d +n)\s *([+-])\s *(\d +)\s *\) / ($1 $2 $3 )/ g ;
111
+ # $_[0] =~ s/\(\s*(\d+n)\s*([+-])\s*(\d+)\s*\)/($1 $2 $3)/g;
112
+ # empty file (only linebreaks)
113
+ $_ [0] =~ s / ^(?:\r ?\n )+$// g ;
106
114
}
107
115
};
108
116
@@ -176,7 +184,7 @@ sub stdmsg
176
184
$stderr =~ s / ^(?:DEPRECATION )?WARNING(?:[^\n ]+\n )*\n *// gm ;
177
185
}
178
186
# clean error messages
179
- $stderr =~ s / ^Error(?:[^\n ]+\n )*\n *// gm ;
187
+ $stderr =~ s / ^(?:Internal )? Error(?:[^\n ]+\n )*\n *// gm ;
180
188
$stderr =~ s /\n .*\Z // s ;
181
189
utf8::decode($stderr );
182
190
return $stderr ;
@@ -272,8 +280,13 @@ sub execute
272
280
$spec -> query(' prec' ),
273
281
' output_style' ,
274
282
$spec -> style,
283
+ ' include_paths' ,
284
+ [abs_path(' t/sass-spec/spec' )],
285
+ ' dont_die' , 1
275
286
);
276
287
288
+ my $cwd = getcwd();
289
+ chdir (dirname($spec -> {file }));
277
290
my $comp = CSS::Sass-> new(%options );
278
291
279
292
# save stderr
@@ -282,17 +295,20 @@ sub execute
282
295
283
296
# redirect stderr to file
284
297
open (STDERR , " +>:raw:utf8" , " specs.stderr.log" ); select (STDERR ); $| = 1;
285
- my $css = eval { $comp -> compile_file($spec -> {file }) }; my $err = $@ ;
286
- sysseek(STDERR , 0, 0); sysread (STDERR , my $msg , 65536); close (STDERR );
298
+ my ($css , $stats ) = eval { $comp -> compile_file(basename($spec -> {file })) }; my $err = $@ ;
299
+ sysseek(STDERR , 0, 0); sysread (STDERR , my $msg , 65536);
300
+ close (STDERR ); unlink (" specs.stderr.log" );
287
301
288
302
# reset stderr
289
303
open STDERR , ' >&OLDFH' ;
290
304
291
305
# store the results
292
306
$spec -> {css } = $css ;
293
- $spec -> {err } = $err ;
307
+ $spec -> {err } = $stats -> { " error_message " } ;
294
308
$spec -> {msg } = $msg ;
295
309
310
+ chdir ($cwd );
311
+
296
312
# return the results
297
313
return $css , $err ;
298
314
@@ -315,6 +331,8 @@ sub query { shift->{root}->query(@_); }
315
331
# ###############################################################################
316
332
package main ;
317
333
# ###############################################################################
334
+ our $unpackOnce ; BEGIN { $unpackOnce = 0; }
335
+ # ###############################################################################
318
336
319
337
use Carp qw( croak) ;
320
338
@@ -339,6 +357,7 @@ sub write_file($$)
339
357
# ********************************************************************
340
358
sub unpack_hrx ()
341
359
{
360
+ return if $unpackOnce && -f ' t/sass-spec/.unpacked' ;
342
361
my @dirs = ([' t/sass-spec/spec' , new DIR]);
343
362
# walk through all directories
344
363
# no recursion for performance
@@ -374,10 +393,16 @@ sub unpack_hrx()
374
393
closedir ($dh );
375
394
376
395
}
396
+ # Mark that it was unpacked
397
+ if ($unpackOnce ) {
398
+ write_file(' t/sass-spec/.unpacked' , ' ' );
399
+ }
377
400
}
378
401
# ********************************************************************
379
402
sub revert_hrx ()
380
403
{
404
+ return if $unpackOnce && -f ' t/sass-spec/.unpacked' ;
405
+ unlink ' t/sass-spec/.unpacked' if -f ' t/sass-spec/.unpacked' ;
381
406
my @dirs = ([' t/sass-spec/spec' , new DIR]);
382
407
# walk through all directories
383
408
# no recursion for performance
@@ -443,11 +468,11 @@ sub load_tests()
443
468
$test -> {style } = $yaml -> {' :output_style' };
444
469
$test -> {start } = $yaml -> {' :start_version' };
445
470
$test -> {end } = $yaml -> {' :end_version' };
446
- $test -> {ignore } = grep /^ libsass$ /i,
471
+ $test -> {ignore } = grep /libsass/i,
447
472
@{$yaml -> {' :ignore_for' } || []};
448
- $test -> {wtodo } = grep /^ libsass$ /i,
473
+ $test -> {wtodo } = grep /libsass/i,
449
474
@{$yaml -> {' :warning_todo' } || []};
450
- $test -> {todo } = grep /^ libsass$ /i,
475
+ $test -> {todo } = grep /libsass/i,
451
476
@{$yaml -> {' :todo' } || []};
452
477
}
453
478
0 commit comments