Skip to content

Commit

Permalink
Merge pull request os-autoinst#1101 from okurz/feature/productdir
Browse files Browse the repository at this point in the history
Allow relative paths in PRODUCTDIR as well
  • Loading branch information
okurz authored Feb 8, 2019
2 parents a715336 + 49c72bc commit a27d1d2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion doc/backend_vars.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Supported variables per backend
|====================
Variable;Values allowed;Default value;Explanation
CASEDIR;string;;Path to test distribution. Can be a git repository URL of a test distribution to checkout with an optional refspec into the current directory. Tries to follow the definition of https://docs.npmjs.com/files/package.json#git-urls-as-dependencies , for example `git@github.com:os-autoinst/os-autoinst-distri-opensuse.git#feature/test`
PRODUCTDIR;string;;Path to optional "product directory" which includes the test schedule entry point "main.pm" as well as a "needles" subdirectory with the needles to load.
PRODUCTDIR;string;;Path to optional "product directory" which includes the test schedule entry point "main.pm" as well as a "needles" subdirectory with the needles to load. Can be relative path.
NEEDLES_DIR;string;;Path to needles subdirectory to use, defaults to "needles" within `PRODUCTDIR`. Can be a git repository URL, comparable to `CASEDIR`
INCLUDE_MODULES;string;;comma separated names or fullnames of test modules to be included while excluding all that do not match, e.g. "boot,mod1"
EXCLUDE_MODULES;string;;comma separated names or fullnames of test modules to exclude. Can be combined with INCLUDE_MODULES and has precedence, e.g. to additionally exclude modules based on an include-list
Expand Down
1 change: 1 addition & 0 deletions isotovideo
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ if ($bmwqemu::vars{SCHEDULE}) {
autotest::loadtest($_ . '.pm') foreach split(',', $bmwqemu::vars{SCHEDULE});
$bmwqemu::vars{INCLUDE_MODULES} = 'none';
}
unshift @INC, '.' unless File::Spec->file_name_is_absolute($bmwqemu::vars{PRODUCTDIR});
if (-e $bmwqemu::vars{PRODUCTDIR} . '/main.pm') {
require $bmwqemu::vars{PRODUCTDIR} . '/main.pm';
}
Expand Down
19 changes: 16 additions & 3 deletions t/14-isotovideo.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use strict;
use warnings;
use autodie ':all';
use Test::More;
use File::Basename;
use File::Path 'remove_tree';
Expand All @@ -25,7 +26,7 @@ sub is_in_log {

subtest 'standalone isotovideo without vars.json file and only command line parameters' => sub {
chdir($pool_dir);
unlink('vars.json');
unlink('vars.json') if -e 'vars.json';
isotovideo(opts => "casedir=$data_dir/tests schedule=foo,bar/baz _exit_after_schedule=1");
is_in_log('scheduling.*foo', 'requested modules are run as part of enforced scheduled');
is_in_log('scheduling.*bar/baz', 'requested modules in subdirs are scheduled');
Expand All @@ -49,8 +50,8 @@ EOV

subtest 'isotovideo with custom git repo parameters specified' => sub {
chdir($pool_dir);
unlink('vars.json');
mkdir('repo.git');
unlink('vars.json') if -e 'vars.json';
mkdir('repo.git') unless -d 'repo.git';
qx{git init -q --bare repo.git};
# Ensure the checkout folder does not exist so that git clone tries to
# create a new checkout on every test run
Expand All @@ -61,4 +62,16 @@ subtest 'isotovideo with custom git repo parameters specified' => sub {
is_in_log('No scripts', 'the repo actually has no test definitions');
};

subtest 'productdir variable relative/absolute' => sub {
chdir($pool_dir);
unlink('vars.json') if -e 'vars.json';
isotovideo(opts => "casedir=$data_dir/tests _exit_after_schedule=1 productdir=$data_dir/tests");
is_in_log('\d* scheduling.*shutdown', 'schedule has been evaluated');
mkdir('product') unless -e 'product';
mkdir('product/foo') unless -e 'product/foo';
symlink("$data_dir/tests/main.pm", "$pool_dir/product/foo/main.pm") unless -e "$pool_dir/product/foo/main.pm";
isotovideo(opts => "casedir=$data_dir/tests _exit_after_schedule=1 productdir=product/foo");
is_in_log('\d* scheduling.*shutdown', 'schedule can still be found');
};

done_testing();

0 comments on commit a27d1d2

Please sign in to comment.