CSS-Sass

 view release on metacpan or  search on metacpan

t/99_sass_specs.t  view on Meta::CPAN

	$variants = $do_nested
	          + $do_compact
	          + $do_expanded
	          + $do_compressed;
}

BEGIN
{

	our $todo = 0;
	$die_first = 0;
	my $skip_huge = 0;
	my $skip_todo = 1;

	@dirs = ('t/sass-spec/spec');

	while (my $dir = shift(@dirs))
	{
		opendir(my $dh, $dir) or die "error opening specs dir $dir";
		while (my $ent = readdir($dh))
		{
			local $todo = $todo;
			next if $ent eq ".";
			next if $ent eq "..";
			next if $ent =~ m/^\./;
			next if $ent =~ m/input\.disabled\.scss$/;
			$todo = $todo || $ent eq "todo" ||
				$ent eq "libsass-todo-tests" ||
				$ent eq "libsass-todo-issues";
			my $path = join("/", $dir, $ent);
			next if $ent eq "huge" && $skip_huge;
			next if($todo && $skip_todo);
			push @dirs, $path if -d $path;
			if ($ent =~ m/^input\./)
			{
				push @tests, [$dir, $ent];
			}
		}
		closedir($dh);
	}

	# warn "found ", scalar(@tests), " spec tests\n";
	# warn join(", ", map { $_->[0] } @tests), "\n";

}

#foreach my $test (@tests) {
#  my $tst = $test->[0];
#  $tst =~ s/t\/+sass-spec\/+//;
#  warn "git mv",
#       " ", $tst, "/expected_output.css ",
#       " ", $tst, "/expected.nested.css ",
#  "\n";
#}
#exit(1);

# uncomment to debug a single test case
# @tests = grep { $_->[0] =~ m/199/ } @tests;

use Test::More tests => $variants * ($redo_sass ? 2 : 1) * scalar(@tests);
use Test::Differences;

use CSS::Sass;

sub read_file
{
  use Carp;
  local $/ = undef;
  open my $fh, "<:raw:utf8", $_[0] or croak "Couldn't open file: <", $_[0], ">: $!";
  binmode $fh; return <$fh>;
}

my $sass;
my ($r, $err);
my ($src, $expect);

# work directly on arg
# lib/sass_spec/test_case.rb
sub clean_output ($) {
	$_[0] =~ s/[\r\n\s	 ]+/ /g;
	$_[0] =~ s/,[\r\n\s	 ]+/,/g;
}
sub norm_output ($) {
	$_[0] =~ s/\r//g;
	$_[0] =~ s/\s+([{,])/$1/g;
	# $_[0] =~ s/#ff0/yellow/g;
	$_[0] =~ s/(?:\r?\n)+/\n/g;
	$_[0] =~ s/(?:\r?\n)+$/\n/g;
}

my @false_negatives;

my %options;
my @cmds;
foreach my $test (@tests)
{

	my $input_file = join("/", $test->[0], $test->[1]);
	my $output_nested = join("/", $test->[0], 'expected_output.css');
	my $output_compact = join("/", $test->[0], 'expected.compact.css');
	my $output_expanded = join("/", $test->[0], 'expected.expanded.css');
	my $output_compressed = join("/", $test->[0], 'expected.compressed.css');

	eval('use Win32::Process;');
	eval('use Win32;');

	if ($redo_sass)
	{
		unless (-f join("/", $test->[0], 'redo.skip')) {
			push @cmds, ["C:\\Ruby\\193\\bin\\sass -E utf-8 --unix-newlines --sourcemap=none -t nested -C \"$input_file\" \"$output_nested\"", $input_file] if ($do_nested);
			push @cmds, ["C:\\Ruby\\193\\bin\\sass -E utf-8 --unix-newlines --sourcemap=none -t compact -C \"$input_file\" \"$output_compact\"", $input_file] if ($do_compact);
			push @cmds, ["C:\\Ruby\\193\\bin\\sass -E utf-8 --unix-newlines --sourcemap=none -t expanded -C \"$input_file\" \"$output_expanded\"", $input_file] if ($do_expanded);
			push @cmds, ["C:\\Ruby\\193\\bin\\sass -E utf-8 --unix-newlines --sourcemap=none -t compressed -C \"$input_file\" \"$output_compressed\"", $input_file] if ($do_compressed);
		} else {
			SKIP: { skip("dont redo expected_output.css", 1) if ($do_nested); }
			SKIP: { skip("dont redo expected.compact.css", 1) if ($do_compact); }
			SKIP: { skip("dont redo expected.expanded.css", 1) if ($do_expanded); }
			SKIP: { skip("dont redo expected.compressed.css", 1) if ($do_compressed); }
		}
	}
}



( run in 1.088 second using v1.01-cache-2.11-cpan-df04353d9ac )