1
1
#! /usr/bin/env bash
2
- set -ex
2
+ set -exo pipefail
3
3
4
4
# Test script for FPM features functionality
5
5
# Usage: ./test_features.sh [fpm_executable]
@@ -20,37 +20,37 @@ echo "=== Testing features_demo package ==="
20
20
pushd " features_demo"
21
21
echo " Test 1: Basic debug feature"
22
22
rm -rf build
23
- " $fpm " run --features debug | tee output.txt
23
+ " $fpm " run --features debug > output.txt
24
24
grep -q " DEBUG mode enabled" output.txt || { echo " ERROR: DEBUG mode not enabled" ; exit 1; }
25
25
echo " ✓ Debug feature works"
26
26
27
27
# Test 2: Profile usage - development profile (includes debug)
28
- echo " Test 2: Development profile (debug feature)"
28
+ echo " Test 2: Development profile (debug feature)"
29
29
rm -rf build
30
- " $fpm " run --profile development --target features_demo | tee output.txt
30
+ " $fpm " run --profile development --target features_demo > output.txt
31
31
grep -q " DEBUG mode enabled" output.txt || { echo " ERROR: DEBUG mode not enabled in development profile" ; exit 1; }
32
32
echo " ✓ Development profile works"
33
33
34
34
# Test 3: Multiple features
35
35
echo " Test 3: Multiple features (debug + openmp)"
36
- rm -rf build
37
- " $fpm " run --features debug,openmp --target features_demo | tee output.txt
36
+ rm -rf build
37
+ " $fpm " run --features debug,openmp --target features_demo > output.txt
38
38
grep -q " DEBUG mode enabled" output.txt || { echo " ERROR: DEBUG mode not enabled with multiple features" ; exit 1; }
39
39
grep -q " OpenMP support enabled" output.txt || { echo " ERROR: OpenMP not enabled with multiple features" ; exit 1; }
40
40
echo " ✓ Multiple features work"
41
41
42
42
# Test 4: Feature-specific executable (debug_demo only available with debug feature)
43
43
echo " Test 4: Feature-specific executable"
44
44
rm -rf build
45
- " $fpm " run --features debug --target debug_demo | tee output.txt
45
+ " $fpm " run --features debug --target debug_demo > output.txt
46
46
grep -q " Debug Demo Program" output.txt || { echo " ERROR: Debug Demo Program not found" ; exit 1; }
47
47
grep -q " Debug mode: ON" output.txt || { echo " ERROR: Debug mode not ON in debug_demo" ; exit 1; }
48
48
echo " ✓ Feature-specific executable works"
49
49
50
50
# Test 5: Profile with multiple features - production profile (release + openmp)
51
51
echo " Test 5: Production profile (release + openmp)"
52
52
rm -rf build
53
- " $fpm " run --profile production --target features_demo | tee output.txt
53
+ " $fpm " run --profile production --target features_demo > output.txt
54
54
grep -q " RELEASE mode enabled" output.txt || { echo " ERROR: RELEASE mode not enabled in production profile" ; exit 1; }
55
55
grep -q " OpenMP support enabled" output.txt || { echo " ERROR: OpenMP not enabled in production profile" ; exit 1; }
56
56
# Should NOT have debug
@@ -62,8 +62,8 @@ echo "✓ Production profile works"
62
62
63
63
# Test 6: No features - baseline behavior
64
64
echo " Test 6: No features (baseline)"
65
- rm -rf build
66
- " $fpm " run --target features_demo | tee output.txt
65
+ rm -rf build
66
+ " $fpm " run --target features_demo > output.txt
67
67
# Should have neither DEBUG nor RELEASE without explicit features
68
68
if grep -q " DEBUG mode enabled" output.txt; then
69
69
echo " ERROR: DEBUG mode should not be enabled in baseline"
@@ -127,23 +127,23 @@ rm -rf build
127
127
# Test 11: Debug dependency feature
128
128
echo " Test 11: Debug dependency feature"
129
129
rm -rf build
130
- " $fpm " run --features with_feat_debug | tee output.txt
130
+ " $fpm " run --features with_feat_debug > output.txt
131
131
grep -q " WITH_DEBUG_DEPENDENCY" output.txt || { echo " ERROR: WITH_DEBUG_DEPENDENCY not found" ; exit 1; }
132
132
grep -q " DEBUG mode enabled" output.txt || { echo " ERROR: DEBUG mode not enabled in dependency test" ; exit 1; }
133
133
echo " ✓ Debug dependency feature works"
134
134
135
135
# Test 12: Release dependency feature
136
136
echo " Test 12: Release dependency feature"
137
137
rm -rf build
138
- " $fpm " run --features with_feat_release | tee output.txt
138
+ " $fpm " run --features with_feat_release > output.txt
139
139
grep -q " WITH_RELEASE_DEPENDENCY" output.txt || { echo " ERROR: WITH_RELEASE_DEPENDENCY not found" ; exit 1; }
140
140
grep -q " RELEASE mode enabled" output.txt || { echo " ERROR: RELEASE mode not enabled in dependency test" ; exit 1; }
141
141
echo " ✓ Release dependency feature works"
142
142
143
143
# Test 13: Multi dependency feature
144
144
echo " Test 13: Multi dependency feature"
145
145
rm -rf build
146
- " $fpm " run --features with_feat_multi | tee output.txt
146
+ " $fpm " run --features with_feat_multi > output.txt
147
147
grep -q " WITH_MULTI_DEPENDENCY" output.txt || { echo " ERROR: WITH_MULTI_DEPENDENCY not found" ; exit 1; }
148
148
grep -q " DEBUG mode enabled" output.txt || { echo " ERROR: DEBUG mode not enabled in multi dependency test" ; exit 1; }
149
149
grep -q " MPI support enabled" output.txt || { echo " ERROR: MPI support not enabled in multi dependency test" ; exit 1; }
@@ -152,7 +152,7 @@ echo "✓ Multi dependency feature works"
152
152
# Test 14: Profile with dependency features
153
153
echo " Test 14: Debug dependency profile"
154
154
rm -rf build
155
- " $fpm " run --profile debug_dep | tee output.txt
155
+ " $fpm " run --profile debug_dep > output.txt
156
156
grep -q " WITH_DEBUG_DEPENDENCY" output.txt || { echo " ERROR: WITH_DEBUG_DEPENDENCY not found in profile test" ; exit 1; }
157
157
grep -q " DEBUG mode enabled" output.txt || { echo " ERROR: DEBUG mode not enabled in dependency profile test" ; exit 1; }
158
158
echo " ✓ Debug dependency profile works"
@@ -169,7 +169,7 @@ pushd "features_per_compiler"
169
169
# Test 15: Development profile (debug + verbose)
170
170
echo " Test 15: Features per compiler - development profile"
171
171
rm -rf build
172
- if " $fpm " run --profile development | tee output.txt; then
172
+ if " $fpm " run --profile development > output.txt; then
173
173
echo " ✓ Exit code 0 (success) as expected"
174
174
else
175
175
echo " ERROR: Expected exit code 0 but got non-zero exit code"
@@ -189,7 +189,7 @@ echo "✓ Development profile works"
189
189
# Test 16: Production profile (release + fast)
190
190
echo " Test 16: Features per compiler - production profile"
191
191
rm -rf build
192
- if " $fpm " run --profile production | tee output.txt; then
192
+ if " $fpm " run --profile production > output.txt; then
193
193
echo " ✓ Exit code 0 (success) as expected"
194
194
else
195
195
echo " ERROR: Expected exit code 0 but got non-zero exit code"
@@ -213,7 +213,7 @@ echo "✓ Production profile works"
213
213
# Test 17: Testing profile (debug + strict)
214
214
echo " Test 17: Features per compiler - testing profile"
215
215
rm -rf build
216
- if " $fpm " run --profile testing | tee output.txt; then
216
+ if " $fpm " run --profile testing > output.txt; then
217
217
echo " ✓ Exit code 0 (success) as expected"
218
218
else
219
219
echo " ERROR: Expected exit code 0 but got non-zero exit code"
@@ -232,7 +232,7 @@ echo "✓ Testing profile works"
232
232
# Test 18: Individual features - debug only
233
233
echo " Test 18: Features per compiler - debug feature only"
234
234
rm -rf build
235
- if " $fpm " run --features debug | tee output.txt; then
235
+ if " $fpm " run --features debug > output.txt; then
236
236
echo " ✓ Exit code 0 (success) as expected"
237
237
else
238
238
echo " ERROR: Expected exit code 0 but got non-zero exit code"
@@ -251,7 +251,7 @@ echo "✓ Debug feature works"
251
251
# Test 19: Individual features - release only
252
252
echo " Test 19: Features per compiler - release feature only"
253
253
rm -rf build
254
- if " $fpm " run --features release | tee output.txt; then
254
+ if " $fpm " run --features release > output.txt; then
255
255
echo " ✓ Exit code 0 (success) as expected"
256
256
else
257
257
echo " ERROR: Expected exit code 0 but got non-zero exit code"
@@ -270,7 +270,7 @@ echo "✓ Release feature works"
270
270
# Test 20: No profile/features - baseline
271
271
echo " Test 20: Features per compiler - baseline (no profile)"
272
272
rm -rf build
273
- if " $fpm " run | tee output.txt; then
273
+ if " $fpm " run > output.txt; then
274
274
echo " ✓ Exit code 0 (success) as expected"
275
275
else
276
276
echo " ERROR: Expected exit code 0 but got non-zero exit code"
0 commit comments