Skip to content

Commit f847311

Browse files
committed
catch error messages correctly
1 parent cb2e5fc commit f847311

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

ci/test_features.sh

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
set -ex
2+
set -exo pipefail
33

44
# Test script for FPM features functionality
55
# Usage: ./test_features.sh [fpm_executable]
@@ -20,37 +20,37 @@ echo "=== Testing features_demo package ==="
2020
pushd "features_demo"
2121
echo "Test 1: Basic debug feature"
2222
rm -rf build
23-
"$fpm" run --features debug | tee output.txt
23+
"$fpm" run --features debug > output.txt
2424
grep -q "DEBUG mode enabled" output.txt || { echo "ERROR: DEBUG mode not enabled"; exit 1; }
2525
echo "✓ Debug feature works"
2626

2727
# Test 2: Profile usage - development profile (includes debug)
28-
echo "Test 2: Development profile (debug feature)"
28+
echo "Test 2: Development profile (debug feature)"
2929
rm -rf build
30-
"$fpm" run --profile development --target features_demo | tee output.txt
30+
"$fpm" run --profile development --target features_demo > output.txt
3131
grep -q "DEBUG mode enabled" output.txt || { echo "ERROR: DEBUG mode not enabled in development profile"; exit 1; }
3232
echo "✓ Development profile works"
3333

3434
# Test 3: Multiple features
3535
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
3838
grep -q "DEBUG mode enabled" output.txt || { echo "ERROR: DEBUG mode not enabled with multiple features"; exit 1; }
3939
grep -q "OpenMP support enabled" output.txt || { echo "ERROR: OpenMP not enabled with multiple features"; exit 1; }
4040
echo "✓ Multiple features work"
4141

4242
# Test 4: Feature-specific executable (debug_demo only available with debug feature)
4343
echo "Test 4: Feature-specific executable"
4444
rm -rf build
45-
"$fpm" run --features debug --target debug_demo | tee output.txt
45+
"$fpm" run --features debug --target debug_demo > output.txt
4646
grep -q "Debug Demo Program" output.txt || { echo "ERROR: Debug Demo Program not found"; exit 1; }
4747
grep -q "Debug mode: ON" output.txt || { echo "ERROR: Debug mode not ON in debug_demo"; exit 1; }
4848
echo "✓ Feature-specific executable works"
4949

5050
# Test 5: Profile with multiple features - production profile (release + openmp)
5151
echo "Test 5: Production profile (release + openmp)"
5252
rm -rf build
53-
"$fpm" run --profile production --target features_demo | tee output.txt
53+
"$fpm" run --profile production --target features_demo > output.txt
5454
grep -q "RELEASE mode enabled" output.txt || { echo "ERROR: RELEASE mode not enabled in production profile"; exit 1; }
5555
grep -q "OpenMP support enabled" output.txt || { echo "ERROR: OpenMP not enabled in production profile"; exit 1; }
5656
# Should NOT have debug
@@ -62,8 +62,8 @@ echo "✓ Production profile works"
6262

6363
# Test 6: No features - baseline behavior
6464
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
6767
# Should have neither DEBUG nor RELEASE without explicit features
6868
if grep -q "DEBUG mode enabled" output.txt; then
6969
echo "ERROR: DEBUG mode should not be enabled in baseline"
@@ -127,23 +127,23 @@ rm -rf build
127127
# Test 11: Debug dependency feature
128128
echo "Test 11: Debug dependency feature"
129129
rm -rf build
130-
"$fpm" run --features with_feat_debug | tee output.txt
130+
"$fpm" run --features with_feat_debug > output.txt
131131
grep -q "WITH_DEBUG_DEPENDENCY" output.txt || { echo "ERROR: WITH_DEBUG_DEPENDENCY not found"; exit 1; }
132132
grep -q "DEBUG mode enabled" output.txt || { echo "ERROR: DEBUG mode not enabled in dependency test"; exit 1; }
133133
echo "✓ Debug dependency feature works"
134134

135135
# Test 12: Release dependency feature
136136
echo "Test 12: Release dependency feature"
137137
rm -rf build
138-
"$fpm" run --features with_feat_release | tee output.txt
138+
"$fpm" run --features with_feat_release > output.txt
139139
grep -q "WITH_RELEASE_DEPENDENCY" output.txt || { echo "ERROR: WITH_RELEASE_DEPENDENCY not found"; exit 1; }
140140
grep -q "RELEASE mode enabled" output.txt || { echo "ERROR: RELEASE mode not enabled in dependency test"; exit 1; }
141141
echo "✓ Release dependency feature works"
142142

143143
# Test 13: Multi dependency feature
144144
echo "Test 13: Multi dependency feature"
145145
rm -rf build
146-
"$fpm" run --features with_feat_multi | tee output.txt
146+
"$fpm" run --features with_feat_multi > output.txt
147147
grep -q "WITH_MULTI_DEPENDENCY" output.txt || { echo "ERROR: WITH_MULTI_DEPENDENCY not found"; exit 1; }
148148
grep -q "DEBUG mode enabled" output.txt || { echo "ERROR: DEBUG mode not enabled in multi dependency test"; exit 1; }
149149
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"
152152
# Test 14: Profile with dependency features
153153
echo "Test 14: Debug dependency profile"
154154
rm -rf build
155-
"$fpm" run --profile debug_dep | tee output.txt
155+
"$fpm" run --profile debug_dep > output.txt
156156
grep -q "WITH_DEBUG_DEPENDENCY" output.txt || { echo "ERROR: WITH_DEBUG_DEPENDENCY not found in profile test"; exit 1; }
157157
grep -q "DEBUG mode enabled" output.txt || { echo "ERROR: DEBUG mode not enabled in dependency profile test"; exit 1; }
158158
echo "✓ Debug dependency profile works"
@@ -169,7 +169,7 @@ pushd "features_per_compiler"
169169
# Test 15: Development profile (debug + verbose)
170170
echo "Test 15: Features per compiler - development profile"
171171
rm -rf build
172-
if "$fpm" run --profile development | tee output.txt; then
172+
if "$fpm" run --profile development > output.txt; then
173173
echo "✓ Exit code 0 (success) as expected"
174174
else
175175
echo "ERROR: Expected exit code 0 but got non-zero exit code"
@@ -189,7 +189,7 @@ echo "✓ Development profile works"
189189
# Test 16: Production profile (release + fast)
190190
echo "Test 16: Features per compiler - production profile"
191191
rm -rf build
192-
if "$fpm" run --profile production | tee output.txt; then
192+
if "$fpm" run --profile production > output.txt; then
193193
echo "✓ Exit code 0 (success) as expected"
194194
else
195195
echo "ERROR: Expected exit code 0 but got non-zero exit code"
@@ -213,7 +213,7 @@ echo "✓ Production profile works"
213213
# Test 17: Testing profile (debug + strict)
214214
echo "Test 17: Features per compiler - testing profile"
215215
rm -rf build
216-
if "$fpm" run --profile testing | tee output.txt; then
216+
if "$fpm" run --profile testing > output.txt; then
217217
echo "✓ Exit code 0 (success) as expected"
218218
else
219219
echo "ERROR: Expected exit code 0 but got non-zero exit code"
@@ -232,7 +232,7 @@ echo "✓ Testing profile works"
232232
# Test 18: Individual features - debug only
233233
echo "Test 18: Features per compiler - debug feature only"
234234
rm -rf build
235-
if "$fpm" run --features debug | tee output.txt; then
235+
if "$fpm" run --features debug > output.txt; then
236236
echo "✓ Exit code 0 (success) as expected"
237237
else
238238
echo "ERROR: Expected exit code 0 but got non-zero exit code"
@@ -251,7 +251,7 @@ echo "✓ Debug feature works"
251251
# Test 19: Individual features - release only
252252
echo "Test 19: Features per compiler - release feature only"
253253
rm -rf build
254-
if "$fpm" run --features release | tee output.txt; then
254+
if "$fpm" run --features release > output.txt; then
255255
echo "✓ Exit code 0 (success) as expected"
256256
else
257257
echo "ERROR: Expected exit code 0 but got non-zero exit code"
@@ -270,7 +270,7 @@ echo "✓ Release feature works"
270270
# Test 20: No profile/features - baseline
271271
echo "Test 20: Features per compiler - baseline (no profile)"
272272
rm -rf build
273-
if "$fpm" run | tee output.txt; then
273+
if "$fpm" run > output.txt; then
274274
echo "✓ Exit code 0 (success) as expected"
275275
else
276276
echo "ERROR: Expected exit code 0 but got non-zero exit code"

0 commit comments

Comments
 (0)