Skip to content

Commit e4d823f

Browse files
committed
test/system: Connect system tests to Meson
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
1 parent 96bc4d4 commit e4d823f

File tree

6 files changed

+101
-31
lines changed

6 files changed

+101
-31
lines changed

meson.build

+1-28
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ endif
1616
go = find_program('go')
1717
go_md2man = find_program('go-md2man')
1818
shellcheck = find_program('shellcheck', required: false)
19-
skopeo = find_program('skopeo', required: false)
2019

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

36-
if not skopeo.found()
37-
message('Running system tests requires Skopeo for OCI image manipulation.')
38-
endif
39-
40-
install_subdir(
41-
'test',
42-
install_dir: join_paths(get_option('datadir'), meson.project_name()),
43-
exclude_files: [
44-
'system/libs/bats-assert/.git',
45-
'system/libs/bats-assert/.gitignore',
46-
'system/libs/bats-assert/.travis.yml',
47-
'system/libs/bats-assert/package.json',
48-
'system/libs/bats-support/.git',
49-
'system/libs/bats-support/.gitignore',
50-
'system/libs/bats-support/.travis.yml',
51-
'system/libs/bats-support/package.json'
52-
],
53-
exclude_directories: [
54-
'system/libs/bats-assert/.git',
55-
'system/libs/bats-assert/script',
56-
'system/libs/bats-assert/test',
57-
'system/libs/bats-support/.git',
58-
'system/libs/bats-support/script',
59-
'system/libs/bats-support/test'
60-
]
61-
)
62-
6335
subdir('data')
6436
subdir('doc')
6537
subdir('profile.d')
6638
subdir('src')
39+
subdir('test')
6740
if get_option('install_completions')
6841
subdir('completion')
6942
endif

playbooks/system-test.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
- hosts: all
33
tasks:
44
- name: Run system tests
5-
command: bats --timing ./test/system
5+
command: meson test --suite system
66
environment:
77
PODMAN: '/usr/bin/podman'
88
TOOLBOX: '/usr/local/bin/toolbox'
99
args:
10-
chdir: '{{ zuul.project.src_dir }}'
10+
chdir: '{{ zuul.project.src_dir }}/builddir'

src/meson.build

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ endif
4747

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

50-
custom_target(
50+
toolbox = custom_target(
5151
'toolbox',
5252
build_by_default: true,
5353
command: [

test/meson.build

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
subdir('system')

test/system/libs/meson.build

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
system_tests_libs_dir = system_tests_dir / 'libs'
2+
3+
system_tests_libs_files = files(
4+
'helpers.bash'
5+
)
6+
7+
install_data(
8+
install_dir: system_tests_libs_dir,
9+
sources: system_tests_libs_files
10+
)
11+
12+
install_subdir(
13+
'bats-support',
14+
install_dir: system_tests_libs_dir,
15+
exclude_files: [
16+
'.git',
17+
'.gitignore',
18+
'.travis.yml',
19+
'package.json'
20+
],
21+
exclude_directories: [
22+
'.git',
23+
'script',
24+
'test'
25+
]
26+
)
27+
28+
install_subdir(
29+
'bats-assert',
30+
install_dir: system_tests_libs_dir,
31+
exclude_files: [
32+
'.git',
33+
'.gitignore',
34+
'.travis.yml',
35+
'package.json'
36+
],
37+
exclude_directories: [
38+
'.git',
39+
'script',
40+
'test'
41+
]
42+
)

test/system/meson.build

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
system_tests_dir = get_option('datadir') / meson.project_name() / 'test'
2+
3+
awk = find_program('awk', required: false)
4+
bats = find_program('bats', required: false)
5+
htpasswd = find_program('htpasswd', required: false)
6+
openssl = find_program('openssl', required: false)
7+
podman = find_program('podman', required: false)
8+
skopeo = find_program('skopeo', required: false)
9+
10+
system_tests_files = files(
11+
'000-setup.bats',
12+
'001-version.bats',
13+
'002-help.bats',
14+
'101-create.bats',
15+
'102-list.bats',
16+
'103-container.bats',
17+
'104-run.bats',
18+
'105-enter.bats',
19+
'106-rm.bats',
20+
'107-rmi.bats',
21+
'999-teardown.bats',
22+
'README.md'
23+
)
24+
25+
if fs.exists('/run/.containerenv')
26+
warning('System tests can not be run in a container.')
27+
elif not awk.found() or not bats.found() or not htpasswd.found() or not openssl.found() or not podman.found() or not skopeo.found()
28+
warning('System tests require: awk, bats, htpasswd, openssl, podman and skopeo being installed.')
29+
else
30+
system_tests_env = environment()
31+
system_tests_env.set('TOOLBOX', toolbox.full_path())
32+
33+
test(
34+
'system tests',
35+
bats,
36+
args: [
37+
'--formatter', 'tap',
38+
'--timing',
39+
'./'],
40+
depends: toolbox,
41+
env: system_tests_env,
42+
protocol: 'tap',
43+
suite: 'system',
44+
timeout: 900,
45+
workdir: meson.current_source_dir()
46+
)
47+
endif
48+
49+
install_data(
50+
install_dir: system_tests_dir,
51+
sources: system_tests_files
52+
)
53+
54+
subdir('libs')

0 commit comments

Comments
 (0)