Skip to content

Commit 5fb354d

Browse files
committed
testsuite: add tabs to t0026-flux-R.t
Problem: t0026-flux-R.t uses 4 spaces to indent sharness tests, but using TABs for these tests is de-facto standard and allows better use of indented here-docs (`cat <<-EOF`). Switch test_expect_success() indents to TAB instead of 4 spaces in this test. Additionally add support for emitting a logfile when FLUX_TESTS_LOGFILE is set in the environment.
1 parent 92a6915 commit 5fb354d

File tree

1 file changed

+140
-138
lines changed

1 file changed

+140
-138
lines changed

t/t0026-flux-R.t

Lines changed: 140 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -2,212 +2,214 @@
22

33
test_description='Test flux-R front-end command'
44

5+
# Append --logfile option if FLUX_TESTS_LOGFILE is set in environment
6+
test -n "$FLUX_TESTS_LOGFILE" && set -- "$@" --logfile
57
. `dirname $0`/sharness.sh
68

79
test_expect_success 'flux R fails on invalid R objects' '
8-
test_expect_code 1 flux R decode </dev/null &&
9-
echo {} | test_expect_code 1 flux R decode &&
10-
echo "{\"version\": 1}" | test_expect_code 1 flux R decode &&
11-
echo "{\"version\": 1, \"execution\": {}}" \
12-
| test_expect_code 1 flux R decode
10+
test_expect_code 1 flux R decode </dev/null &&
11+
echo {} | test_expect_code 1 flux R decode &&
12+
echo "{\"version\": 1}" | test_expect_code 1 flux R decode &&
13+
echo "{\"version\": 1, \"execution\": {}}" \
14+
| test_expect_code 1 flux R decode
1315
'
1416
test_expect_success 'flux R decode works with empty R_lite' '
15-
echo "{\"version\": 1, \"execution\": {\"R_lite\": {}}}" \
16-
| flux R decode > R.empty &&
17-
test $(flux R decode --count core < R.empty) -eq 0
17+
echo "{\"version\": 1, \"execution\": {\"R_lite\": {}}}" \
18+
| flux R decode > R.empty &&
19+
test $(flux R decode --count core < R.empty) -eq 0
1820
'
1921
test_expect_success 'flux R encode with no args creates expected result' '
20-
flux R encode | flux R decode &&
21-
test $(flux R encode | flux R decode --count node) -eq 1 &&
22-
test $(flux R encode | flux R decode --count core) -eq 1 &&
23-
test $(flux R encode | flux R decode --count gpu) -eq 0 &&
24-
test "$(flux R encode | flux R decode --short)" = "rank0/core0"
22+
flux R encode | flux R decode &&
23+
test $(flux R encode | flux R decode --count node) -eq 1 &&
24+
test $(flux R encode | flux R decode --count core) -eq 1 &&
25+
test $(flux R encode | flux R decode --count gpu) -eq 0 &&
26+
test "$(flux R encode | flux R decode --short)" = "rank0/core0"
2527
'
2628
test_expect_success 'flux R encode --ranks works' '
27-
test $(flux R encode --ranks 0-1 | flux R decode --count node) -eq 2 &&
28-
test $(flux R encode --ranks 0,2 | flux R decode --count node) -eq 2 &&
29-
test $(flux R encode --ranks 0,2 | flux R decode --count core) -eq 2 &&
30-
test $(flux R encode --ranks 0,2 | flux R decode --ranks) = "0,2"
29+
test $(flux R encode --ranks 0-1 | flux R decode --count node) -eq 2 &&
30+
test $(flux R encode --ranks 0,2 | flux R decode --count node) -eq 2 &&
31+
test $(flux R encode --ranks 0,2 | flux R decode --count core) -eq 2 &&
32+
test $(flux R encode --ranks 0,2 | flux R decode --ranks) = "0,2"
3133
'
3234
test_expect_success 'flux R encode --cores works ' '
33-
test $(flux R encode --cores 0-1 | flux R decode --count node) -eq 1 &&
34-
test $(flux R encode --cores 0-1 | flux R decode --count core) -eq 2 &&
35-
test $(flux R encode -c 0-1 -r 0-1 | flux R decode -c core) -eq 4
35+
test $(flux R encode --cores 0-1 | flux R decode --count node) -eq 1 &&
36+
test $(flux R encode --cores 0-1 | flux R decode --count core) -eq 2 &&
37+
test $(flux R encode -c 0-1 -r 0-1 | flux R decode -c core) -eq 4
3638
'
3739
test_expect_success 'flux R encode --gpus works' '
38-
test $(flux R encode --gpus 0 | flux R decode --count node) -eq 1 &&
39-
test $(flux R encode --gpus 0 | flux R decode --count gpu) -eq 1 &&
40-
test $(flux R encode --gpus 0 | flux R decode --count core) -eq 0 &&
41-
test $(flux R encode --cores 0-1 -g 0 | flux R decode --count core) -eq 2 &&
42-
test $(flux R encode --cores 0-1 -g 0 | flux R decode --count gpu) -eq 1
40+
test $(flux R encode --gpus 0 | flux R decode --count node) -eq 1 &&
41+
test $(flux R encode --gpus 0 | flux R decode --count gpu) -eq 1 &&
42+
test $(flux R encode --gpus 0 | flux R decode --count core) -eq 0 &&
43+
test $(flux R encode --cores 0-1 -g 0 | flux R decode --count core) -eq 2 &&
44+
test $(flux R encode --cores 0-1 -g 0 | flux R decode --count gpu) -eq 1
4345
'
4446
test_expect_success 'flux R encode --hosts works' '
45-
test $(flux R encode --hosts=foo[0-1] | flux R decode -c node) -eq 2 &&
46-
hosts=$(flux R encode --hosts=foo[0-1] | flux R decode --nodelist) &&
47-
test "$hosts" = "foo[0-1]"
47+
test $(flux R encode --hosts=foo[0-1] | flux R decode -c node) -eq 2 &&
48+
hosts=$(flux R encode --hosts=foo[0-1] | flux R decode --nodelist) &&
49+
test "$hosts" = "foo[0-1]"
4850
'
4951
test_expect_success 'flux R encode/decode --property works' '
50-
flux R encode --hosts=foo[0-1] --gpus 0 --cores 0-1 \
51-
--property xx:0 \
52-
--property yy:1 \
53-
--property all > properties.json &&
54-
test $(flux R decode -c node <properties.json) -eq 2 &&
55-
test $(flux R decode -c node --properties all <properties.json) -eq 2 &&
56-
test $(flux R decode -c node --properties xx <properties.json) -eq 1 &&
57-
test $(flux R decode -c node --properties yy <properties.json) -eq 1 &&
58-
test $(flux R decode -c node --properties ^all <properties.json) -eq 0 &&
59-
test $(flux R decode -c node --properties all,yy <properties.json) -eq 1 &&
60-
test $(flux R decode --nodelist --properties xx <properties.json) = foo0 &&
61-
test $(flux R decode --nodelist --properties yy <properties.json) = foo1 &&
62-
test $(flux R decode --nodelist --properties ^yy <properties.json) = foo0
52+
flux R encode --hosts=foo[0-1] --gpus 0 --cores 0-1 \
53+
--property xx:0 \
54+
--property yy:1 \
55+
--property all > properties.json &&
56+
test $(flux R decode -c node <properties.json) -eq 2 &&
57+
test $(flux R decode -c node --properties all <properties.json) -eq 2 &&
58+
test $(flux R decode -c node --properties xx <properties.json) -eq 1 &&
59+
test $(flux R decode -c node --properties yy <properties.json) -eq 1 &&
60+
test $(flux R decode -c node --properties ^all <properties.json) -eq 0 &&
61+
test $(flux R decode -c node --properties all,yy <properties.json) -eq 1 &&
62+
test $(flux R decode --nodelist --properties xx <properties.json) = foo0 &&
63+
test $(flux R decode --nodelist --properties yy <properties.json) = foo1 &&
64+
test $(flux R decode --nodelist --properties ^yy <properties.json) = foo0
6365
'
6466
test_expect_success 'flux R encode --property fails with invalid rank' '
65-
test_must_fail flux R encode -r 0-3 -p xx:3-5 >property-fail.out 2>&1 &&
66-
test_debug "cat property-fail.out" &&
67-
grep "ranks 4-5 not found" property-fail.out
67+
test_must_fail flux R encode -r 0-3 -p xx:3-5 >property-fail.out 2>&1 &&
68+
test_debug "cat property-fail.out" &&
69+
grep "ranks 4-5 not found" property-fail.out
6870
'
6971
test_expect_success 'flux R encode --xml works' '
70-
flux R encode --xml=$SHARNESS_TEST_SRCDIR/hwloc-data/sierra2/0.xml \
71-
> R.sierra2 &&
72-
result=$(flux R decode --short < R.sierra2) &&
73-
test_debug "echo encode XML = $result" &&
74-
test "$result" = "rank0/core[0-43],gpu[0-3]"
72+
flux R encode --xml=$SHARNESS_TEST_SRCDIR/hwloc-data/sierra2/0.xml \
73+
> R.sierra2 &&
74+
result=$(flux R decode --short < R.sierra2) &&
75+
test_debug "echo encode XML = $result" &&
76+
test "$result" = "rank0/core[0-43],gpu[0-3]"
7577
'
7678
test_expect_success 'flux R encode --xml works with AMD RSMI gpus' '
77-
flux R encode --xml=$SHARNESS_TEST_SRCDIR/hwloc-data/corona/0.xml \
78-
> R.corona &&
79-
result=$(flux R decode --short < R.corona) &&
80-
test_debug "echo encode XML = $result" &&
81-
test "$result" = "rank0/core[0-47],gpu[0-7]"
79+
flux R encode --xml=$SHARNESS_TEST_SRCDIR/hwloc-data/corona/0.xml \
80+
> R.corona &&
81+
result=$(flux R decode --short < R.corona) &&
82+
test_debug "echo encode XML = $result" &&
83+
test "$result" = "rank0/core[0-47],gpu[0-7]"
8284
'
8385
test_expect_success 'flux R decode --include works' '
84-
result=$(flux R encode -r 0-1023 | flux R decode --include 5-7 --short) &&
85-
test_debug "echo $result" &&
86-
test "$result" = "rank[5-7]/core0"
86+
result=$(flux R encode -r 0-1023 | flux R decode --include 5-7 --short) &&
87+
test_debug "echo $result" &&
88+
test "$result" = "rank[5-7]/core0"
8789
'
8890
test_expect_success 'flux R decode --exclude works' '
89-
result=$(flux R encode -r 1-10 | flux R decode --exclude 5-7 --short) &&
90-
test_debug "echo $result" &&
91-
test "$result" = "rank[1-4,8-10]/core0"
91+
result=$(flux R encode -r 1-10 | flux R decode --exclude 5-7 --short) &&
92+
test_debug "echo $result" &&
93+
test "$result" = "rank[1-4,8-10]/core0"
9294
'
9395
test_expect_success 'flux R append fails if R sets intersect' '
94-
(flux R encode -r 0-1 && flux R encode -r 1-2) \
95-
| test_must_fail flux R append &&
96-
(flux R encode -r 0-1 -c 0-1 -g 0 && flux R encode -r 1 -c 2-3 -g 0) \
97-
| test_must_fail flux R append
96+
(flux R encode -r 0-1 && flux R encode -r 1-2) \
97+
| test_must_fail flux R append &&
98+
(flux R encode -r 0-1 -c 0-1 -g 0 && flux R encode -r 1 -c 2-3 -g 0) \
99+
| test_must_fail flux R append
98100
'
99101
test_expect_success 'flux R append works' '
100-
result=$( (flux R encode -r 0-1 -c 0-1 && flux R encode -r 1-2 -c 2-3) \
101-
| flux R append | flux R decode --short) &&
102-
test_debug "echo $result" &&
103-
test "$result" = "rank0/core[0-1] rank1/core[0-3] rank2/core[2-3]"
102+
result=$( (flux R encode -r 0-1 -c 0-1 && flux R encode -r 1-2 -c 2-3) \
103+
| flux R append | flux R decode --short) &&
104+
test_debug "echo $result" &&
105+
test "$result" = "rank0/core[0-1] rank1/core[0-3] rank2/core[2-3]"
104106
'
105107
test_expect_success 'flux R append works when only some nodes have gpus' '
106-
result=$( (flux R encode -r 0-1 -c 0-1 && \
108+
result=$( (flux R encode -r 0-1 -c 0-1 && \
107109
flux R encode -r 2-3 -c 0-1 -g 0-1) \
108-
| flux R append | flux R decode --short) &&
109-
test_debug "echo $result" &&
110-
test "$result" = "rank[0-1]/core[0-1] rank[2-3]/core[0-1],gpu[0-1]"
110+
| flux R append | flux R decode --short) &&
111+
test_debug "echo $result" &&
112+
test "$result" = "rank[0-1]/core[0-1] rank[2-3]/core[0-1],gpu[0-1]"
111113
'
112114

113115
test_expect_success 'flux R diff works' '
114-
result=$( (flux R encode -r 0-1 -c 0-1 && flux R encode -r 0-1 -c 0) \
115-
| flux R diff | flux R decode --short) &&
116-
test_debug "echo $result" &&
117-
test "$result" = "rank[0-1]/core1"
116+
result=$( (flux R encode -r 0-1 -c 0-1 && flux R encode -r 0-1 -c 0) \
117+
| flux R diff | flux R decode --short) &&
118+
test_debug "echo $result" &&
119+
test "$result" = "rank[0-1]/core1"
118120
'
119121
test_expect_success 'flux R intersect works' '
120-
result=$( (flux R encode -r 0-3 -c 0-1 && flux R encode -r 1-5 -c 0) \
121-
| flux R intersect | flux R decode --short) &&
122-
test_debug "echo $result" &&
123-
test "$result" = "rank[1-3]/core0" &&
124-
result=$( (flux R encode -r 0-3 -c 0-1 && flux R encode -r 4-5 -c 0) \
125-
| flux R intersect | flux R decode --short) &&
126-
test_debug "echo $result" &&
127-
test -z "$result"
122+
result=$( (flux R encode -r 0-3 -c 0-1 && flux R encode -r 1-5 -c 0) \
123+
| flux R intersect | flux R decode --short) &&
124+
test_debug "echo $result" &&
125+
test "$result" = "rank[1-3]/core0" &&
126+
result=$( (flux R encode -r 0-3 -c 0-1 && flux R encode -r 4-5 -c 0) \
127+
| flux R intersect | flux R decode --short) &&
128+
test_debug "echo $result" &&
129+
test -z "$result"
128130
'
129131
test_expect_success 'flux R remap works' '
130-
result=$(flux R encode -r 5,99,1000 | flux R remap | flux R decode -s) &&
131-
test_debug "echo $result" &&
132-
test "$result" = "rank[0-2]/core0"
132+
result=$(flux R encode -r 5,99,1000 | flux R remap | flux R decode -s) &&
133+
test_debug "echo $result" &&
134+
test "$result" = "rank[0-2]/core0"
133135
'
134136
test_expect_success 'flux R rerank works' '
135-
result=$(flux R encode -r 0-3 -H foo[0-3] \
136-
| flux R rerank foo[3,2,1,0] | flux R decode --nodelist) &&
137-
test_debug "echo reranked $result" &&
138-
test "$result" = "foo[3,2,1,0]"
137+
result=$(flux R encode -r 0-3 -H foo[0-3] \
138+
| flux R rerank foo[3,2,1,0] | flux R decode --nodelist) &&
139+
test_debug "echo reranked $result" &&
140+
test "$result" = "foo[3,2,1,0]"
139141
'
140142
test_expect_success 'flux R verify works' '
141-
result=$( (flux R encode -r 1-10 -c 0-3 && flux R encode -r 1 -c 0-3) \
142-
| flux R verify 2>&1) &&
143-
test_debug "echo $result"
143+
result=$( (flux R encode -r 1-10 -c 0-3 && flux R encode -r 1 -c 0-3) \
144+
| flux R verify 2>&1) &&
145+
test_debug "echo $result"
144146
'
145147
test_expect_success 'flux R verify fails with mismatched ranks' '
146-
result=$( (flux R encode -r 1-10 -c 0-3 && flux R encode -r 0 -c 0-3) \
147-
| test_must_fail flux R verify 2>&1) &&
148-
test_debug "echo $result"
148+
result=$( (flux R encode -r 1-10 -c 0-3 && flux R encode -r 0 -c 0-3) \
149+
| test_must_fail flux R verify 2>&1) &&
150+
test_debug "echo $result"
149151
'
150152
test_expect_success 'flux R verify fails with mismatched hosts' '
151-
result=$( (flux R encode -r 1 -c 0-3 -H foo1 \
152-
&& flux R encode -r 1 -c 0-3 -H foo12) \
153-
| test_must_fail flux R verify 2>&1) &&
154-
test_debug "echo $result"
153+
result=$( (flux R encode -r 1 -c 0-3 -H foo1 \
154+
&& flux R encode -r 1 -c 0-3 -H foo12) \
155+
| test_must_fail flux R verify 2>&1) &&
156+
test_debug "echo $result"
155157
'
156158
test_expect_success 'flux R verify fails with mismatched resources' '
157-
(flux R encode -r 1 -c 0-3 && flux R encode -r 1 -c 0-2) \
158-
| test_must_fail flux R verify
159+
(flux R encode -r 1 -c 0-3 && flux R encode -r 1 -c 0-2) \
160+
| test_must_fail flux R verify
159161
'
160162
test_expect_success 'flux R verify reports extra resources' '
161-
(flux R encode -r 1 -c 0-3 && flux R encode -r 1 -c 0-7 -g 1) \
162-
| flux R verify
163+
(flux R encode -r 1 -c 0-3 && flux R encode -r 1 -c 0-7 -g 1) \
164+
| flux R verify
163165
'
164166
test_expect_success 'flux R set-property works' '
165-
flux R encode -r 0-1 -c 0-3 -H foo[0-1] | \
166-
flux R set-property all | \
167-
flux R set-property xx:0 yy:1 > setprop.json &&
168-
test $(flux R decode -c node <setprop.json) -eq 2 &&
169-
test $(flux R decode -c node --properties all <setprop.json) -eq 2 &&
170-
test $(flux R decode -c node --properties xx <setprop.json) -eq 1 &&
171-
test $(flux R decode -c node --properties yy <setprop.json) -eq 1 &&
172-
test $(flux R decode -c node --properties ^all <setprop.json) -eq 0 &&
173-
test $(flux R decode -c node --properties all,yy <setprop.json) -eq 1 &&
174-
test $(flux R decode --nodelist --properties xx <setprop.json) = foo0 &&
175-
test $(flux R decode --nodelist --properties yy <setprop.json) = foo1 &&
176-
test $(flux R decode --nodelist --properties ^yy <setprop.json) = foo0
167+
flux R encode -r 0-1 -c 0-3 -H foo[0-1] | \
168+
flux R set-property all | \
169+
flux R set-property xx:0 yy:1 > setprop.json &&
170+
test $(flux R decode -c node <setprop.json) -eq 2 &&
171+
test $(flux R decode -c node --properties all <setprop.json) -eq 2 &&
172+
test $(flux R decode -c node --properties xx <setprop.json) -eq 1 &&
173+
test $(flux R decode -c node --properties yy <setprop.json) -eq 1 &&
174+
test $(flux R decode -c node --properties ^all <setprop.json) -eq 0 &&
175+
test $(flux R decode -c node --properties all,yy <setprop.json) -eq 1 &&
176+
test $(flux R decode --nodelist --properties xx <setprop.json) = foo0 &&
177+
test $(flux R decode --nodelist --properties yy <setprop.json) = foo1 &&
178+
test $(flux R decode --nodelist --properties ^yy <setprop.json) = foo0
177179
'
178180
test_expect_success 'flux R set-property fails with unknown ranks' '
179-
flux R encode -r 0-1 | test_must_fail flux R set-property foo:1-2
181+
flux R encode -r 0-1 | test_must_fail flux R set-property foo:1-2
180182
'
181183
test_expect_success HAVE_JQ 'scheduling opaque key is preserved' '
182-
flux R encode -r 0-3 -c 0-3 -g 0 -H foo[0-3] \
183-
| jq ".scheduling = 42" > R.orig &&
184-
flux R decode < R.orig | jq -e ".scheduling == 42" &&
185-
flux R decode --include 0 < R.orig | jq -e ".scheduling == 42" &&
186-
flux R decode --exclude 0 < R.orig | jq -e ".scheduling == 42"
184+
flux R encode -r 0-3 -c 0-3 -g 0 -H foo[0-3] \
185+
| jq ".scheduling = 42" > R.orig &&
186+
flux R decode < R.orig | jq -e ".scheduling == 42" &&
187+
flux R decode --include 0 < R.orig | jq -e ".scheduling == 42" &&
188+
flux R decode --exclude 0 < R.orig | jq -e ".scheduling == 42"
187189
'
188190
test_expect_success HAVE_JQ 'scheduling opaque key is preserved with append' '
189-
(cat R.orig && flux R encode -r 4 ) | flux R append \
190-
| flux R decode | jq -e ".scheduling == 42"
191+
(cat R.orig && flux R encode -r 4 ) | flux R append \
192+
| flux R decode | jq -e ".scheduling == 42"
191193
'
192194
test_expect_success HAVE_JQ 'scheduling opaque key is preserved with remap' '
193-
flux R remap < R.orig | flux R decode | jq -e ".scheduling == 42"
195+
flux R remap < R.orig | flux R decode | jq -e ".scheduling == 42"
194196
'
195197
test_expect_success HAVE_JQ 'scheduling opaque key is preserved with diff' '
196-
(cat R.orig && flux R encode -r 1 ) | flux R diff \
197-
| jq -e ".scheduling == 42"
198+
(cat R.orig && flux R encode -r 1 ) | flux R diff \
199+
| jq -e ".scheduling == 42"
198200
'
199201
test_expect_success HAVE_JQ 'scheduling key is preserved with intersect' '
200-
(cat R.orig && flux R encode -r 1 -H foo1) | flux R intersect \
201-
| jq -e ".scheduling == 42"
202+
(cat R.orig && flux R encode -r 1 -H foo1) | flux R intersect \
203+
| jq -e ".scheduling == 42"
202204
'
203205
test_expect_success HAVE_JQ 'use of --local,--xml and --hosts is supported' '
204-
ncores=$(flux R encode --local | flux R decode --count cores) &&
205-
flux R encode --local --hosts=fluke[0-16] > R.hosts &&
206-
test_debug "flux R decode --short < R.hosts" &&
207-
count=$(flux R decode --count cores < R.hosts) &&
208-
test "$count" = "$ncores" &&
209-
hosts=$(flux R decode --nodelist < R.hosts) &&
210-
test_debug "echo got $hosts" &&
211-
test "$hosts" = "fluke[0-16]"
206+
ncores=$(flux R encode --local | flux R decode --count cores) &&
207+
flux R encode --local --hosts=fluke[0-16] > R.hosts &&
208+
test_debug "flux R decode --short < R.hosts" &&
209+
count=$(flux R decode --count cores < R.hosts) &&
210+
test "$count" = "$ncores" &&
211+
hosts=$(flux R decode --nodelist < R.hosts) &&
212+
test_debug "echo got $hosts" &&
213+
test "$hosts" = "fluke[0-16]"
212214
'
213215
test_done

0 commit comments

Comments
 (0)