File: package.t

package info (click to toggle)
libtap-harness-junit-perl 0.42-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 856 kB
  • sloc: xml: 10,187; perl: 413; makefile: 2
file content (94 lines) | stat: -rw-r--r-- 2,762 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl

use TAP::Harness::JUnit;
use Test::More;
use XML::Simple;
use File::Temp;
use File::Basename;
use Encode;

my %tests = (
	package => 'Package prefix test',
);

plan tests => 8 * int (keys %tests);

my $our_cat  = [$^X, qw/-ne print/];
my $our_cat2 = join(' ', @$our_cat);

foreach my $test (keys %tests) {
	my $model = dirname($0)."/tests/$test.xml";
	my $outfile = File::Temp->new (UNLINK => 0)->filename;

	my $harness = new TAP::Harness::JUnit ({
		xmlfile     => $outfile,
		verbosity   => -1,
		merge       => 1,
		exec        => $our_cat,
		notimes     => 1,
	});

	$harness->runtests ([dirname($0)."/tests/$test.txt" => $tests{$test}]);

	# Repeat with explicit empty package
	my $outfile_p0 = File::Temp->new (UNLINK => 0)->filename;

	my $harness_p0 = new TAP::Harness::JUnit ({
		xmlfile     => $outfile_p0,
		package     => '',
		verbosity   => -1,
		merge       => 1,
		exec        => $our_cat,
		notimes     => 1,
	});

	$harness_p0->runtests ([dirname($0)."/tests/$test.txt" => $tests{$test}]);

	# Repeat with a defined package
	my $model_pkg  = dirname($0)."/tests/$test.qqq.xml";
	my $outfile_p1 = File::Temp->new (UNLINK => 0)->filename;

	my $harness_p1 = new TAP::Harness::JUnit ({
		xmlfile     => $outfile_p1,
		package     => 'QQQ',
		verbosity   => -1,
		merge       => 1,
		exec        => $our_cat,
		notimes     => 1,
	});

	$harness_p1->runtests ([dirname($0)."/tests/$test.txt" => $tests{$test}]);

	# Repeat with package in ENV
	my $outfile_p2 = File::Temp->new (UNLINK => 0)->filename;
	$ENV{JUNIT_PACKAGE} = 'QQQ';
	my $harness_p2 = new TAP::Harness::JUnit ({
		xmlfile     => $outfile_p2,
		verbosity   => -1,
		merge       => 1,
		exec        => $our_cat,
		notimes     => 1,
	});

	$harness_p2->runtests ([dirname($0)."/tests/$test.txt" => $tests{$test}]);

	is_deeply (XMLin ($outfile), XMLin ($model), "Output of $test (no package) matches model");
	eval { decode ('UTF-8', `$our_cat2 $outfile`, Encode::FB_CROAK) };
	ok (!$@, "Output of $test is valid UTF-8");
	unlink $outfile;

	is_deeply (XMLin ($outfile_p0), XMLin ($model), "Output of $test (empty package) matches model");
	eval { decode ('UTF-8', `$our_cat2 $outfile_p0`, Encode::FB_CROAK) };
	ok (!$@, "Output of $test is valid UTF-8");
	unlink $outfile_p0;

	is_deeply (XMLin ($outfile_p1), XMLin ($model_pkg), "Output of $test (defined package) matches model");
	eval { decode ('UTF-8', `$our_cat2 $outfile_p1`, Encode::FB_CROAK) };
	ok (!$@, "Output of $test is valid UTF-8");
	unlink $outfile_p1;

	is_deeply (XMLin ($outfile_p2), XMLin ($model_pkg), "Output of $test (package through ENV) matches model");
	eval { decode ('UTF-8', `$our_cat2 $outfile_p2`, Encode::FB_CROAK) };
	ok (!$@, "Output of $test is valid UTF-8");
	unlink $outfile_p2;
}