Project

General

Profile

Actions

action #104670

closed

Fix circular dependency of autotest <-> bmwqemu

Added by tinita almost 3 years ago. Updated over 2 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
Regressions/Crashes
Target version:
Start date:
2022-03-28
Due date:
% Done:

100%

Estimated time:
(Total: 0.00 h)

Description

Motivation

See https://github.com/os-autoinst/os-autoinst/pull/1905 which fixes the circular dep bmwqemu -> backend::driver -> myjsonrpc -> bmwqemu

autotest uses bmwqemu. bmwqemu uses $autotest::current_test in one of its functions and does a require autotest for this.

Correct solution would be to move $autotest::current_test to its own module, that both bmwqemu and autotest can use.

Problem: Backwards compatibility


Subtasks


Related issues 1 (0 open1 closed)

Is duplicate of openQA Project (public) - action #78240: prevent circular dependencies in bmwqemu.pm and autotest.pm to be able to use "strictures"Resolved2020-11-19

Actions
Actions #1

Updated by tinita almost 3 years ago

One solution could be a tied scalar (using () parens to visualize the tied value):

% cat currenttest.pm
package currenttest;
use strict;
use warnings;
use experimental 'signatures';
use base 'Tie::Scalar';
use base 'Exporter';
our @EXPORT_OK = qw(current_test set_current_test);

my $current_test;
sub set_current_test ($value) { $current_test = "($value)" }
sub current_test () { $current_test }

sub TIESCALAR ($class, $value) {
    set_current_test($value);
    return bless {}, $class;
}

sub FETCH ($self) { current_test() }
sub STORE ($self, $value) { set_current_test($value) }

1;

% cat tiedscalar.pl
package main;
use 5.010;
use strict;
use warnings;

use currenttest qw(current_test set_current_test);

tie my $s, 'currenttest', "foo";
say $s;
$s = 23;
say $s;
set_current_test("method call");
say $s;

my $new = $s;
$new = "new";
say $new;

% perl -I. tiedscalar.pl
(foo)
(23)
(method call)
new

This way the old $autotest::current_test variable could stay where it is for old code that uses it, but it would be tied to the new variable in currenttest.pm, which we could also use in our internal code.

Actions #2

Updated by tinita almost 3 years ago

  • Description updated (diff)
Actions #3

Updated by tinita almost 3 years ago

  • Status changed from New to Resolved
  • Assignee set to tinita
  • Target version changed from future to Ready
Actions #4

Updated by tinita almost 3 years ago

  • Is duplicate of action #78240: prevent circular dependencies in bmwqemu.pm and autotest.pm to be able to use "strictures" added
Actions

Also available in: Atom PDF