diff --git a/OpenQA/Isotovideo/NeedleDownloader.pm b/OpenQA/Isotovideo/NeedleDownloader.pm index 34f84ca07a1..2162a599c2a 100644 --- a/OpenQA/Isotovideo/NeedleDownloader.pm +++ b/OpenQA/Isotovideo/NeedleDownloader.pm @@ -72,7 +72,7 @@ sub _add_download { my $needle_name = $needle->{name}; my $latest_update = $needle->{t_updated}; - my $needles_dir = $needle::needles_dir; + my $needles_dir = needle::needles_dir(); my $download_target = "$needles_dir/$needle_name.$extension"; if (my $target_stat = stat($download_target)) { diff --git a/needle.pm b/needle.pm index 1e9c8c12bca..13c99008437 100644 --- a/needle.pm +++ b/needle.pm @@ -33,9 +33,10 @@ use OpenQA::Benchmark::Stopwatch; our %needles; our %tags; -our $needles_dir; our $cleanuphandler; +my $needles_dir; + sub is_click_point_valid { my ($click_point) = @_; return (ref $click_point eq 'HASH' @@ -340,6 +341,10 @@ sub init { return $needles_dir; } +sub needles_dir { $needles_dir; } + +sub set_needles_dir { ($needles_dir) = @_; } + sub tags { my ($wanted) = @_; my @wanted = split(/ /, $wanted); diff --git a/t/01-test_needle.t b/t/01-test_needle.t index e1e6e55e3cb..41ca84b3e8e 100755 --- a/t/01-test_needle.t +++ b/t/01-test_needle.t @@ -397,7 +397,7 @@ subtest 'needle::init accepts custom NEEDLES_DIR within working directory and ot }; subtest 'click point' => sub { - $needle::needles_dir = $misc_needles_dir; + needle::set_needles_dir($misc_needles_dir); my $needle = needle->new('click-point.json'); is_deeply($needle->{area}->[0]->{click_point}, {xpos => 2, ypos => 4}, 'click point parsed'); @@ -412,7 +412,7 @@ subtest 'click point' => sub { }; subtest 'workaround property' => sub { - $needle::needles_dir = $misc_needles_dir; + needle::set_needles_dir($misc_needles_dir); my $workaround_string_needle = needle->new('check-workaround-bsc1234567-20190522.json'); my $workaround_hash_needle = needle->new('check-workaround-hash-20190522.json'); diff --git a/t/02-test_ocr.t b/t/02-test_ocr.t index cd70e908dd9..8848d6ced70 100755 --- a/t/02-test_ocr.t +++ b/t/02-test_ocr.t @@ -28,7 +28,7 @@ unless (which('tesseract')) { needle::init; -my $img1 = tinycv::read("$needle::needles_dir/bootmenu.test.png"); +my $img1 = tinycv::read(needle::needles_dir() . '/bootmenu.test.png'); my $needle = needle->new('bootmenu-ocr.ref.json'); my $res = $img1->search($needle); ok(defined $res, 'ocr match 1'); diff --git a/t/21-needle-downloader.t b/t/21-needle-downloader.t index 3da1e6ba1e4..998a8fa87da 100755 --- a/t/21-needle-downloader.t +++ b/t/21-needle-downloader.t @@ -23,8 +23,9 @@ $user_agent_mock->mock(get => sub { }); # setup needle directory -my $needles_dir = $needle::needles_dir = path(tempdir, 'needles_dir'); +my $needles_dir = path(tempdir, 'needles_dir'); ok(make_path($needles_dir), 'create test needle dir under ' . $needles_dir); +needle::set_needles_dir($needles_dir); subtest 'deduce URL for needle download from test variable OPENQA_URL' => sub { $bmwqemu::vars{OPENQA_URL} = 'https://openqa1-opensuse';