+
+sub run_tests {
+ my $test_dir = shift;
+
+ if (-e "$test_dir/skip.test") {
+ my $skip_msg = read_file("$test_dir/skip.test");
+ print "TEST SKIPPED.\n$skip_msg\n";
+ return;
+ }
+
+ my @expected = &addFiles($test_dir, $Tests{$test}->{check},1);
+
+ my @created = &addFiles($workdir, $Tests{$test}->{check}, 0);
+
+ # Copy src-files to work with
+ for my $f (@{$Tests{$test}->{src_files}}) {
+ copy("$test_dir/$f", "$workdir/$f") or die("Copy failed: $!");
+ }
+ print "Unlinking " . join(' ', @created) . "\n";
+ unlink(@created);
+
+ &checkPrecondition();
+ chdir($workdir);
+ my @command = ($lyx_exe, "-userdir", $userdir);
+ if (defined($Tests{$test}->{command_line})) {
+ push(@command, @{$Tests{$test}->{command_line}});
+ }
+ if (defined($Tests{$test}->{commands}->[0])) {
+ if ($qt_version eq "QT5") {
+ push(@command, "-platform", "offscreen");
+ }
+ if (defined($Tests{$test}->{commands}->[1])) { # more than one command
+ push(@command, "-x", "command-sequence " . join(';', @{$Tests{$test}->{commands}}));
+ }
+ else {
+ push(@command, "-x", $Tests{$test}->{commands}->[0]);
+ }
+ }
+
+ &system1(@command);
+
+ for (my $i = 0; defined($created[$i]); $i++) {
+ die("File \"$created[$i]\" not created") if (! -e "$created[$i]");
+
+ if (defined($expected[$i])) {
+ my $res = mycompare($Tests{$test}->{check_type}, $expected[$i], $created[$i], $Tests{$test}->{check_script});
+
+ die("Expected ($expected[$i]) and created ($created[$i]) files differ") if $res != 0;
+ }
+ }
+}
+
+sub checkPrecondition()