forked from ufal/hamledt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
regtest2.pl
executable file
·72 lines (69 loc) · 2.84 KB
/
regtest2.pl
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
#!/usr/bin/env perl
# Regression testing of Treex and HamleDT, part 2.
# This script should be called after all HamleDT treebanks have been built and harmonized using the desired revision of Treex.
# The idea is that the harmonization runs in parallel on the cluster and this script waits until all treebanks are ready, then it does the rest.
# Copyright © 2014 Dan Zeman <[email protected]>
# License: GNU GPL
use utf8;
use open ':utf8';
use IO::Handle; # fdopen()
use lib '/home/zeman/lib';
use dzsys;
sub usage
{
print STDERR ("Usage: regtest2.pl working_folder\n");
}
# The only and obligatory argument of the script is the path to the working folder with TectoMT.
# The environment variables (paths to Treex revision) must be set before this script is invoked!
if(scalar(@ARGV)<1)
{
usage();
die("Missing argument: path to the working folder");
}
my $workdir = $ARGV[0];
# Keep the whole log in the working folder. Redirect STDOUT and STDERR there.
my $log = "$workdir/regtest.log";
open(LOG, ">>$log") or die("Cannot write to $log: $!");
# Last information printed to the original STDOUT:
print("Redirecting STDOUT and STDERR to $log...\n");
STDOUT->fdopen(\*LOG, 'w') or die $!;
STDERR->fdopen(\*LOG, 'w') or die $!;
print("--------------------------------------------------------------------------------\n");
print("Parallel processing finished for all treebanks.\n");
print("--------------------------------------------------------------------------------\n");
# Get the path to this script so we can instruct the cluster to run related scripts.
my $myscriptdir = dzsys::get_script_path();
# Get the other important paths.
my $tmtroot = $workdir.'/tectomt';
my $datapath = $tmtroot.'/share/data/resources/hamledt';
my $testingroot;
my $timestamp;
if($workdir =~ m:^(.+)/(\d+)-\d+$:)
{
$testingroot = $1;
$timestamp = $2;
}
else
{
die("The name of the working folder has an unexpected form: '$workdir'");
}
# Test the newly generated treebank.
my $hatestpath = "$tmtroot/treex/devel/hamledt/tests";
print("Running HamleDT / Prague tests.\n");
dzsys::saferun("cd $hatestpath ; while ! make testall ; do echo New attempt... ; done ; make table | tee $datapath/test.txt");
# Generate name for the data snapshot that we just created.
my $treex_revision = dzsys::chompticks("cd $tmtroot ; svn info | grep -P '^Revision:'");
$treex_revision =~ s/^Revision:\s*//;
my $snapshotid = "hamledt-$timestamp-r$treex_revision";
print("HamleDT snapshot ID = $snapshotid\n");
# Archive the snapshot.
dzsys::saferun("mv $datapath $testingroot/$snapshotid");
# Compare the new snapshot with a previously archived reference snapshot.
if(-d "$testingroot/hamledt-reference")
{
dzsys::saferun("$myscriptdir/hamledtdiff.pl $testingroot/hamledt-reference $testingroot/$snapshotid");
}
else
{
print("Reference snapshot of HamleDT '$testingroot/hamledt-reference' not found.\n");
}