File: dawg11-status.pl

package info (click to toggle)
librdf-query-perl 2.919-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,580 kB
  • sloc: perl: 30,628; javascript: 131; sh: 13; makefile: 2
file content (130 lines) | stat: -rwxr-xr-x 3,404 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env perl

use strict;
use warnings;
no warnings 'uninitialized';
use RDF::Trine;
use RDF::Query;
use RDF::Trine::Error qw(:try);
use Scalar::Util qw(blessed);

my @manifests	= glob( "xt/dawg11/*/manifest.ttl" );
my @files	= scalar(@ARGV) ? @ARGV : glob('earl*11.ttl');
my $model	= RDF::Trine::Model->temporary_model;
my $parser	= RDF::Trine::Parser->new('turtle');
foreach my $f (@files, @manifests) {
	try {
		my $base	= "file://";
		if ($f =~ /manifest/) {
			my ($dir)	= ($f =~ m{xt/dawg11/([^/]+)/manifest.ttl});
			$base	= "http://www.w3.org/2009/sparql/docs/tests/data-sparql11/${dir}/manifest#";
		}
		$parser->parse_file_into_model( $base, $f, $model );
	} catch Error with {
		my $e	= shift;
	};
}

my $query	= RDF::Query->new(<<"END");
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX earl: <http://www.w3.org/ns/earl#>
PREFIX dt: <http://www.w3.org/2001/sw/DataAccess/tests/test-dawg#>
SELECT ?test ?outcome ?approval ?comment
WHERE {
	[] earl:test ?test ; earl:result ?result .
	?result earl:outcome ?outcome .
	OPTIONAL { ?result rdfs:comment ?comment }
	OPTIONAL { ?test dt:approval ?approval }
}
ORDER BY ?test
END

my $iter	= $query->execute( $model );
open( my $git, 'git log|' );
my $rev;
if ($git) {
	my $line;
	do {
		$line	= <$git>;
	} until ($line =~ /^commit (.{7})/);
	if (length($1)) {
		$rev	= "$1";
	}
	close($git);
}

my $date	= scalar(gmtime) . ' GMT';

print <<"END";
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<title>SPARQL 1.1 Evaluation Test Results</title>
<style type="text/css" title="text/css">
/* <![CDATA[ */
			table {
				border: 1px solid #000;
				border-collapse: collapse;
			}
			
			th { background-color: #ddd; }
			td, th {
				padding: 1px 5px 1px 5px;
				border: 1px solid #000;
			}
			
			td.pass { background-color: #0f0; }
			td.fail { background-color: #f00; }
			td.Approved { background-color: #0f0; }
			td.NotClassified { background-color: #ff0; }
/* ]]> */
</style></head>
<body>
<h1>SPARQL 1.1 Test Results for RDF::Query</h1>
<p>As of $date, running with <a href="https://github.com/kasei/perlrdf/commit/$rev">commit $rev</a> (<a href="http://github.com/kasei/perlrdf/tree/master">HEAD of master branch at github</a>)</p>

<table>
<tr>
	<th>Test</th>
	<th>Status</th>
	<th>Result</th>
</tr>
END

my $total	= 0;
my $pass	= 0;
while (my $row = $iter->next) {
	my ($t, $o, $a)	= map { (blessed($_) and $_->can('uri_value')) ? $_->uri_value : $_ } @{ $row }{ qw(test outcome approval comment) };
	my $c	= $row->{comment};
	if ($c) {
		$c	= $c->literal_value;
	}
	$t	=~ s{http://www.w3.org/2001/sw/DataAccess/tests/data-r2/}{};
	$t	=~ s{http://www.w3.org/2009/sparql/docs/tests/data-sparql11/}{};
	$t	=~ s{file:///Users/samofool/data/prog/git/perlrdf/RDF-Query/xt/dawg11/}{};
	$a	=~ s{http://www.w3.org/2001/sw/DataAccess/tests/test-dawg#}{};
	$o	=~ s{http://www.w3.org/ns/earl#}{};
	
	$total++;
	$pass++ if ($o eq 'pass');
	
	print <<"END";
<tr>
	<td>$t</td>
	<td class="$a">$a</td>
	<td class="$o">$o</td>
</tr>
END
}

my $perc	= sprintf('%.1f', (100*$pass/$total));

print <<"END";
</table>
<p>Passed $pass of $total tests (${perc}%).</p>
</body>
</html>
END