Skip to content

Commit

Permalink
test/system: Connect system tests to Meson
Browse files Browse the repository at this point in the history
A bit of plumbing in the build files has been done to accommodate the
change as much as possible. If we're to use meson.build in the
'test/system' subdir we better also install the data from there.

This also adjust the CI playbooks to launch the tests via Meson by
specifying the specific test suite ('system').

#1062
  • Loading branch information
HarryMichal committed May 30, 2022
1 parent 96bc4d4 commit e4d823f
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 31 deletions.
29 changes: 1 addition & 28 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ endif
go = find_program('go')
go_md2man = find_program('go-md2man')
shellcheck = find_program('shellcheck', required: false)
skopeo = find_program('skopeo', required: false)

bash_completion = dependency('bash-completion', required: false)
fish = dependency('fish', required: false)
Expand All @@ -33,37 +32,11 @@ if tmpfilesdir == '' or not fs.exists('/run/.containerenv')
endif
endif

if not skopeo.found()
message('Running system tests requires Skopeo for OCI image manipulation.')
endif

install_subdir(
'test',
install_dir: join_paths(get_option('datadir'), meson.project_name()),
exclude_files: [
'system/libs/bats-assert/.git',
'system/libs/bats-assert/.gitignore',
'system/libs/bats-assert/.travis.yml',
'system/libs/bats-assert/package.json',
'system/libs/bats-support/.git',
'system/libs/bats-support/.gitignore',
'system/libs/bats-support/.travis.yml',
'system/libs/bats-support/package.json'
],
exclude_directories: [
'system/libs/bats-assert/.git',
'system/libs/bats-assert/script',
'system/libs/bats-assert/test',
'system/libs/bats-support/.git',
'system/libs/bats-support/script',
'system/libs/bats-support/test'
]
)

subdir('data')
subdir('doc')
subdir('profile.d')
subdir('src')
subdir('test')
if get_option('install_completions')
subdir('completion')
endif
Expand Down
4 changes: 2 additions & 2 deletions playbooks/system-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
- hosts: all
tasks:
- name: Run system tests
command: bats --timing ./test/system
command: meson test --suite system
environment:
PODMAN: '/usr/bin/podman'
TOOLBOX: '/usr/local/bin/toolbox'
args:
chdir: '{{ zuul.project.src_dir }}'
chdir: '{{ zuul.project.src_dir }}/builddir'
2 changes: 1 addition & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ endif

message('Host machine dynamic linker:', dynamic_linker)

custom_target(
toolbox = custom_target(
'toolbox',
build_by_default: true,
command: [
Expand Down
1 change: 1 addition & 0 deletions test/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
subdir('system')
42 changes: 42 additions & 0 deletions test/system/libs/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
system_tests_libs_dir = system_tests_dir / 'libs'

system_tests_libs_files = files(
'helpers.bash'
)

install_data(
install_dir: system_tests_libs_dir,
sources: system_tests_libs_files
)

install_subdir(
'bats-support',
install_dir: system_tests_libs_dir,
exclude_files: [
'.git',
'.gitignore',
'.travis.yml',
'package.json'
],
exclude_directories: [
'.git',
'script',
'test'
]
)

install_subdir(
'bats-assert',
install_dir: system_tests_libs_dir,
exclude_files: [
'.git',
'.gitignore',
'.travis.yml',
'package.json'
],
exclude_directories: [
'.git',
'script',
'test'
]
)
54 changes: 54 additions & 0 deletions test/system/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
system_tests_dir = get_option('datadir') / meson.project_name() / 'test'

awk = find_program('awk', required: false)
bats = find_program('bats', required: false)
htpasswd = find_program('htpasswd', required: false)
openssl = find_program('openssl', required: false)
podman = find_program('podman', required: false)
skopeo = find_program('skopeo', required: false)

system_tests_files = files(
'000-setup.bats',
'001-version.bats',
'002-help.bats',
'101-create.bats',
'102-list.bats',
'103-container.bats',
'104-run.bats',
'105-enter.bats',
'106-rm.bats',
'107-rmi.bats',
'999-teardown.bats',
'README.md'
)

if fs.exists('/run/.containerenv')
warning('System tests can not be run in a container.')
elif not awk.found() or not bats.found() or not htpasswd.found() or not openssl.found() or not podman.found() or not skopeo.found()
warning('System tests require: awk, bats, htpasswd, openssl, podman and skopeo being installed.')
else
system_tests_env = environment()
system_tests_env.set('TOOLBOX', toolbox.full_path())

test(
'system tests',
bats,
args: [
'--formatter', 'tap',
'--timing',
'./'],
depends: toolbox,
env: system_tests_env,
protocol: 'tap',
suite: 'system',
timeout: 900,
workdir: meson.current_source_dir()
)
endif

install_data(
install_dir: system_tests_dir,
sources: system_tests_files
)

subdir('libs')

0 comments on commit e4d823f

Please sign in to comment.