#!/usr/bin/perl

print "=== Profiling SVG tests for harness ===\n";

$test_file_list = "published_tests.txt";

open(LIST_FH, $test_file_list) or die "\nERROR: could not open file $test_file_list\n";
my @files = <LIST_FH>;
close(LIST_FH);

$svgSrcDir = "../svg";
$svgDstDir = "../svggen";

sub profile
{
	$src=$_[0];
	$dst=$_[1];
	$writing = 'true';

	@svg=`cat $src`;

	open( DEST, ">$dst" );	

	foreach $line ( @svg )
	{
		if( $line =~ /<SVGTestCase/ )
		{
			$writing = 'false';
		}

		if( $writing eq 'true' )
		{
			print DEST $line;
		}

		if( $line =~ /<\/SVGTestCase>/ )
		{
			$writing = 'true';
		}
	}

	close DEST;
}


foreach $file ( @files )
{
	chop $file;

	$dst = $svgDstDir."/".$file;
	$src = $svgSrcDir."/".$file;

    print "Profilng: $file\n";
	profile($src, $dst);
}
