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
+ sudo : yes
25
+
26
+ - name : Obtain the display ID of one successful live display.
27
+ shell : xpra list | grep -m 1 "LIVE.*" | grep -Go [0-9]*$
28
+ register : successful_display
29
+ sudo : yes
30
+
31
+ # Finally, run some tests.
32
+
33
+ - name : Run tests.
34
+ command : make test
35
+ args :
36
+ chdir : " {{ FIDIMAG_INSTALL_PATH }}"
37
+ environment :
38
+ DISPLAY : " :{{ successful_display.stdout }}"
39
+ PYTHONPATH : " {{ FIDIMAG_INSTALL_PATH }}"
40
+ LD_LIBRARY_PATH : " {{ FIDIMAG_INSTALL_PATH }}/local/lib"
41
+ sudo : yes
42
+
43
+ # Cleanup.
44
+
45
+ - name : Stop xpra sessions
46
+ command : xpra stop :{{ item }}
47
+ with_items : XPRA_DISPLAYS
48
+ ignore_errors : yes
49
+ sudo : yes
0 commit comments