aboutsummaryrefslogtreecommitdiff
path: root/tools/build/modules-test.pl
blob: c4b9d0008caeb41546a089c1ed98491e84220a12 (plain)
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
#! perl

use warnings;
use strict;

use Cwd;
use Getopt::Long;

GetOptions('verbose' => \my $verbose);

my $base = shift @ARGV;
my $perl6 = shift @ARGV;
my @failures;

while (<>) {
	# Skip comments
	next if /^\s*(#|$)/;

	# Extract only the module name from the current line
	my ($moduledir) = /(\S+)/;

	if (! -d "$base/modules/$moduledir/t") {
		print "[" . getcwd . "] ...no t/ directory found.\n";
		next;
	}

	# Run the tests through prove
	chdir("$base/modules/$moduledir");

	my @cmd = (
		'prove',
		$verbose ? '-v' : (),
		'-e', $perl6,
		'-r',
		't',
	);

	# Show the command that's going to be ran, for debugging purposes
	print "[" . getcwd . "] @cmd\n";

	# Actually run the command
	my $exit = system "@cmd";

	# Exit early if any errors occurred
	if ($exit) {
		push @failures, $_;
	}

	print "\n";
}

# If we reach this, no errors have been found
if (@failures) {
	print "The following modules failed their tests:\n";

	foreach (@failures) {
		print "- $_\n";
	}

	exit 1;
}