Skip to content

Commit 1ba8e03

Browse files
committed
Add fidimag tests (untested).
1 parent 21647ae commit 1ba8e03

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

roles/fidimag/tasks/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
- include: install_dependencies_from_packages.yml
66
- include: make_fidimag.yml
77
- include: set_paths.yml
8+
- include: test.yml

roles/fidimag/tasks/test.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
# This Ansible playbook runs Fidimag tests. This works because pytest has a
3+
# non-zero exit status if a test fails, and Make returns a non-zero exit status
4+
# if a command returns a non-zero exit status.
5+
6+
# The following task construction exists because XPRA sometimes fails silently,
7+
# apparently stochastically. Hence we attempt to create a number of virtual
8+
# displays using xpra, and test each one. If one of them exists, we continue
9+
# with it. If they all fail, we exit. This is all done to ensure that the
10+
# finmag tests pass, since some of them require a display.
11+
12+
- name: Ensure that xpra is installed
13+
apt:
14+
pkg=xpra
15+
state=latest
16+
update_cache=yes
17+
cache_valid_time=86400
18+
sudo: yes
19+
20+
- name: Create multiple virtual displays and re-probe them.
21+
shell: xpra start :{{ item }} && xpra list
22+
with_items: XPRA_DISPLAYS
23+
ignore_errors: yes
24+
25+
- name: Obtain the display ID of one successful live display.
26+
shell: xpra list | grep -m 1 "LIVE.*" | grep -Go [0-9]*$
27+
register: successful_display
28+
29+
# Finally, run some tests.
30+
31+
- name: Run tests.
32+
command: make test
33+
args:
34+
chdir: "{{ FIDIMAG_INSTALL_PATH }}"
35+
environment:
36+
DISPLAY: ":{{ successful_display.stdout }}"
37+
sudo: yes
38+
39+
# Cleanup.
40+
41+
- name: Stop xpra sessions
42+
command: xpra stop :{{ item }}
43+
with_items: XPRA_DISPLAYS
44+
ignore_errors: yes

roles/fidimag/vars/main.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
---
22
FIDIMAG_REPO_URL: https://github.com/computationalmodelling/fidimag.git
33
FIDIMAG_INSTALL_PATH: /opt/fidimag
4-
FIDIMAG_VERSION: HEAD
4+
FIDIMAG_VERSION: HEAD
5+
6+
xpra_displays:
7+
- 25
8+
- 30
9+
- 36
10+
- 49
11+
- 50
12+
- 64
13+
- 75
14+
- 81
15+
- 90
16+
- 99

0 commit comments

Comments
 (0)