Skip to content

Commit 181a64d

Browse files
committed
feat: allow running extra scrips before tests command
1 parent 48894fd commit 181a64d

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

appimagebuilder/commands/run_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def _load_tests(self, test_settings: {}):
4848
env = ["%s=%s" % (k, v) for k, v in env.items()]
4949

5050
test = ExecutionTest(appdir=self.app_dir, name=name, image=data_accessor.image(),
51-
command=data_accessor.command(), env=env)
51+
command=data_accessor.command(), before_command=data_accessor.before_command(),
52+
env=env)
5253
test_cases.append(test)
5354

5455
return test_cases

appimagebuilder/modules/test/execution_test.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@
2121

2222

2323
class ExecutionTest:
24-
def __init__(self, appdir: Path, name, image, command, env: [str] = None):
24+
def __init__(self, appdir: Path, name, image, command, before_command=None, env: [str] = None):
2525
if env is None:
2626
env = []
2727

2828
self.appdir = appdir
2929
self.name = name
3030
self.image = image
3131
self.command = command
32+
self.before_command = before_command
3233
self.env = env
3334

3435
self.client = docker.from_env()
@@ -62,12 +63,16 @@ def run(self):
6263
container,
6364
accepted_exit_codes=[0, 9],
6465
)
66+
6567
self._run_command(
6668
"mkdir -p /home/%s/.config" % os.getenv("USER"),
6769
container,
6870
user=os.getenv("USER"),
6971
)
7072

73+
if self.before_command:
74+
self._run_command(self.before_command, container)
75+
7176
self.logger.info("command")
7277
self._run_command(self.command, container, user=os.getenv("USER"))
7378
finally:

appimagebuilder/recipe/schema.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def __init__(self):
4848
str: {
4949
"image": str,
5050
"command": str,
51+
Optional("before_command"): self.script,
5152
Optional("use_host_x"): bool,
5253
Optional("env"): {str: Or(str, int, bool)},
5354
}

recipes/bash/AppImageBuilder.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ AppDir:
4949
test:
5050
debian:
5151
image: appimagecrafters/tests-env:debian-stable
52+
before_command: "pwd"
5253
command: "./AppRun ./run_tests.sh"
5354
centos:
5455
image: appimagecrafters/tests-env:centos-7

0 commit comments

Comments
 (0)