Commits

ma...@9ae0c189-cd1f-4510-a509-f4891f5cf20d  committed 07b5e97

HTML parsing tests
Only do memory test if on Linux and pass in MEMORY_TEST=1 to make test

  • Participants
  • Parent commits f243992

Comments (0)

Files changed (2)

File t/11memory.t

 use Test;
-BEGIN { plan tests => $^O eq 'linux' ? 8 : 0 }
+BEGIN { 
+    if ($^O eq 'linux' && $ENV{MEMORY_TEST}) {
+        plan tests => 8;
+    }
+    else {
+        print "1..0 # Skipping test on this platform\n";
+    }
+}
 use XML::LibXML;
-if ($^O eq 'linux') {
+if ($^O eq 'linux' && $ENV{MEMORY_TEST}) {
     ok(1);
     
     warn("BASELINE\n");
+use Test;
+BEGIN { plan tests => 5 }
+use XML::LibXML;
+use IO::File;
+ok(1);
+
+my $html = "example/test.html";
+
+my $parser = XML::LibXML->new();
+my $doc = $parser->parse_html_file($html);
+ok($doc);
+
+undef $doc;
+
+my $fh = IO::File->new($html) || die "Can't open $html: $!";
+
+my $string;
+{
+    local $/;
+    $string = <$fh>;
+}
+
+seek($fh, 0, 0);
+
+ok($string);
+
+$doc = $parser->parse_html_string($string);
+
+ok($doc);
+
+undef $doc;
+
+$doc = $parser->parse_html_fh($fh);
+
+ok($doc);
+
+#warn($doc->toStringHTML);
+