Project

General

Profile

Actions

action #175099

closed

coordination #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

Added by tinita 24 days ago. Updated 10 days ago.

Status:
Resolved
Priority:
Low
Assignee:
Category:
Feature requests
Target version:
Start date:
2025-01-08
Due date:
% Done:

0%

Estimated time:

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';

Related issues 1 (0 open1 closed)

Copied from openQA Project (public) - action #167926: Cover code of os-autoinst path autotest.pm fully (statement coverage) size:SResolvedgpathak2024-10-08

Actions
Actions #1

Updated by tinita 24 days ago

  • Copied from action #167926: Cover code of os-autoinst path autotest.pm fully (statement coverage) size:S added
Actions #2

Updated by okurz 24 days ago

  • Target version set to Ready
Actions #3

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 #4

Updated by gpuliti 16 days ago

  • Assignee set to gpuliti
Actions #5

Updated by okurz 11 days ago

  • Status changed from Workable to In Progress
Actions #7

Updated by gpuliti 10 days ago

  • Status changed from In Progress to Resolved
Actions

Also available in: Atom PDF