Actions
action #175099
closedcoordination #127031: [saga][epic] openQA for SUSE customers
coordination #130414: [epic] Improved code coverage in os-autoinst
autotest::loadtestdir() creates a warning in find_script() and does not add necessary library path size:S
Description
Motivation¶
We have a test directory t/data/tests/tests
with test files like t/data/tests/tests/assert_screen.pm
in there.
(Note the duplicate tests
there, which is confusing and could be improved in our tests, but is a bigger change.)
# test code:
# $bmwqemu::vars{CASEDIR} = 't/data/tests';
# loadtestdir('tests');
# What's happening then:
# loadtest('t/data/tests/tests/assert_screen.pm');
# warning in find_script(): loadtest needs a script below t/data/tests - t/data/tests/tests/assert_screen.pm is not
# $script_path = 'tests/assert_screen.pm';
# Generated code:
package assert_screen;
use lib '.';
use lib 't/data/tests/lib';
use lib 'tests';
require 'tests/assert_screen.pm';
This will fail because we would need t/data/tests
as a library path to find tests/assert_screen.pm
.
Acceptance criteria¶
- AC1: autotest::loadtestdir() should pass correct paths to loadtest() and not end up in warnings
Suggestions¶
Possible fix:
diff --git a/autotest.pm b/autotest.pm
index 49ea19e3..08c00499 100644
--- a/autotest.pm
+++ b/autotest.pm
@@ -461,7 +463,7 @@ sub loadtestdir ($dir) {
$dir =~ s/^\Q$bmwqemu::vars{CASEDIR}\E\/?//; # legacy where absolute path is specified
$dir = join('/', $bmwqemu::vars{CASEDIR}, $dir); # always load from casedir
die "'$dir' does not exist!\n" unless -d $dir;
- loadtest($_) for (glob "$dir/*.pm");
+ loadtest($_) for map { s{^\Q$bmwqemu::vars{CASEDIR}/}{}r } (glob "$dir/*.pm");
}
# This is called if the framework loaded a VM snapshot. All consoles
Outcome:
# test code:
# $bmwqemu::vars{CASEDIR} = 't/data/tests';
# loadtestdir('tests');
# What's happening then:
# loadtest('tests/assert_screen.pm');
# $script_path = 't/data/tests/tests/assert_screen.pm';
# Generated code:
package assert_screen;
use lib '.';
use lib 't/data/tests/lib';
use lib 't/data/tests/tests';
require 't/data/tests/tests/assert_screen.pm';
Updated by tinita 24 days ago
- Copied from action #167926: Cover code of os-autoinst path autotest.pm fully (statement coverage) size:S added
Updated by mkittler 16 days ago
- Subject changed from autotest::loadtestdir() creates a warning in find_script() and does not add necessary library path to autotest::loadtestdir() creates a warning in find_script() and does not add necessary library path size:S
- Description updated (diff)
- Status changed from New to Workable
Actions