Opensuse h4ckweek 2022 navigation log
View the Project on GitHub michelepagot/opensuse.hackweek.2022
by michelepagot
Today I’d like to discuss about an home and lua-ling around. It turn out that I mostly perl-ing around (in a circle).
I have these 3 needles and I’m trying to figure out a good strategy to tag them.
% ls wez*.json |xargs -I{} sh -c $'echo "-----------------"; echo "{}"; cat {}|jq \'.tags\''
-----------------
wezterm-tab-top-20220628.json
[
"wezterm"
]
-----------------
wezterm-tab-top-20220629.json
[
"two-tabs",
"wezterm"
]
-----------------
wezterm-test_terminal-1-20220629.json
[
"test-wezterm-1",
"test_terminal",
"wezterm"
]
In case of two tab opened, I wrongly pretend to match for them like:
assert_screen([qw(wezterm two-tabs)], 10);
It result in openQA to try to match with all the 3 needles.
The right syntax to only have wezterm-tab-top-20220629 used for the matching is:
assert_screen('two-tabs', 10);
First Wezterm set of needles committed.
My idea is to test different Wezterm features by letting the test to load, for each test, a different wezterm.lua
file.
One possibility to implement it in openQA is to consider each wezterm.lua
as a test asset.
Test assets could be static files, stored in a dedicated folder near to the test code. The folder is data. Here an example of an asset.
local wezterm = require 'wezterm';
return {
keys = {
{key="n", mods="SUPER", action=wezterm.action{SpawnTab="CurrentPaneDomain"}},
},
}
openQA also provide some perl functions that help to inject the file in the SUT machine:
Technically it the SUT that retrieve the assets that it needs. These two API are mostly to let the SUT to know the URL where to get the assets from.
openQA also allow the test to generate the assets on the fly or to generate them from a template (e.g data/add_on_products.xml). The template is:
$config =~ s/\{\{NEW_TAB_KEY\}\}/$key/g;
(e.g. generate_dud.pm)
So I can think about creating a template for the SpawnTab key binding.
local wezterm = require 'wezterm';
return {
keys = {
{key="", mods="SUPER", action=wezterm.action{SpawnTab="CurrentPaneDomain"}},
},
}
The Wezterm test is currently executed in a openSUSE Tumbleweed machine. In particular it is executed on a machine booted from a pre-configured HDD image in qcow2 format cloned from https://openqa.opensuse.org/tests/2436441. For some issue it could be tedious to:
But openQA is so kind to provide, on its web interface, a link to download the used qcow2 file, so it can be downloaded locally.
There are different approaches to run it locally:
Some of the Perl topics that I read about today.
sub activate_config() {
my ($self) = shift;
my ($config) = shift;
my %args = @_;
my $cfg_dir = $args{cfg_dir} || '$HOME';
my $cfg_filename = $args{cfg_filename} || '.wezterm.lua';
Regexp to match environment variable name
\$\{?([a-zA-Z0-9\-_]+)\}?
It can be improved as it match $HOME
and ${HOME}
but also ${HOME
.
To be used like
my @locations = ( ['$HOME', '.wezterm.lua'],
['$HOME/.config/wezterm', 'wezterm.lua'],
['$XDG_CONFIG_HOME/wezterm', 'wezterm.lua'],
);
for my $ref (@locations) {
foreach (@$ref) {
my @captured = $_ =~ /\$\{?([a-zA-Z0-9\-_]+)\}?/g;
if( @captured ) {
print "--> ";
print join " # ", @captured;
print "\n";
}
}
}