Skip to content

Commit db45d55

Browse files
committed
better identify debug flags
1 parent 670c67f commit db45d55

File tree

2 files changed

+32
-14
lines changed

2 files changed

+32
-14
lines changed

ci/test_features.sh

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,17 @@ 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 > output.txt; then
172+
if "$fpm" run --profile development > output.txt 2>&1; then
173173
echo "✓ Exit code 0 (success) as expected"
174174
else
175175
echo "ERROR: Expected exit code 0 but got non-zero exit code"
176+
echo "=== Program output ==="
177+
cat output.txt
178+
echo "======================"
176179
exit 1
177180
fi
178181
grep -q "Features Per Compiler Demo" output.txt || { echo "ERROR: Features Per Compiler Demo not found"; exit 1; }
179-
grep -q "✓ DEBUG: -g flag found" output.txt || { echo "ERROR: Debug feature not detected"; exit 1; }
182+
grep -q "✓ DEBUG: debug flags found" output.txt || { echo "ERROR: Debug feature not detected"; exit 1; }
180183
grep -q "✓ VERBOSE: -v flag found" output.txt || { echo "ERROR: Verbose feature not detected"; exit 1; }
181184
grep -q "✓ All compiler flag checks PASSED" output.txt || { echo "ERROR: Expected all checks to pass"; exit 1; }
182185
# Check compiler-specific flags (will depend on detected compiler)
@@ -189,10 +192,13 @@ echo "✓ Development profile works"
189192
# Test 16: Production profile (release + fast)
190193
echo "Test 16: Features per compiler - production profile"
191194
rm -rf build
192-
if "$fpm" run --profile production > output.txt; then
195+
if "$fpm" run --profile production > output.txt 2>&1; then
193196
echo "✓ Exit code 0 (success) as expected"
194197
else
195198
echo "ERROR: Expected exit code 0 but got non-zero exit code"
199+
echo "=== Program output ==="
200+
cat output.txt
201+
echo "======================"
196202
exit 1
197203
fi
198204
grep -q "Features Per Compiler Demo" output.txt || { echo "ERROR: Features Per Compiler Demo not found"; exit 1; }
@@ -213,14 +219,17 @@ echo "✓ Production profile works"
213219
# Test 17: Testing profile (debug + strict)
214220
echo "Test 17: Features per compiler - testing profile"
215221
rm -rf build
216-
if "$fpm" run --profile testing > output.txt; then
222+
if "$fpm" run --profile testing > output.txt 2>&1; then
217223
echo "✓ Exit code 0 (success) as expected"
218224
else
219225
echo "ERROR: Expected exit code 0 but got non-zero exit code"
226+
echo "=== Program output ==="
227+
cat output.txt
228+
echo "======================"
220229
exit 1
221230
fi
222231
grep -q "Features Per Compiler Demo" output.txt || { echo "ERROR: Features Per Compiler Demo not found"; exit 1; }
223-
grep -q "✓ DEBUG: -g flag found" output.txt || { echo "ERROR: Debug feature not detected"; exit 1; }
232+
grep -q "✓ DEBUG: debug flags found" output.txt || { echo "ERROR: Debug feature not detected"; exit 1; }
224233
grep -q "✓ STRICT: standard compliance flags found" output.txt || { echo "ERROR: Strict feature not detected"; exit 1; }
225234
grep -q "✓ All compiler flag checks PASSED" output.txt || { echo "ERROR: Expected all checks to pass"; exit 1; }
226235
# Check compiler-specific flags (will depend on detected compiler)
@@ -232,14 +241,17 @@ echo "✓ Testing profile works"
232241
# Test 18: Individual features - debug only
233242
echo "Test 18: Features per compiler - debug feature only"
234243
rm -rf build
235-
if "$fpm" run --features debug > output.txt; then
244+
if "$fpm" run --features debug > output.txt 2>&1; then
236245
echo "✓ Exit code 0 (success) as expected"
237246
else
238247
echo "ERROR: Expected exit code 0 but got non-zero exit code"
248+
echo "=== Program output ==="
249+
cat output.txt
250+
echo "======================"
239251
exit 1
240252
fi
241253
grep -q "Features Per Compiler Demo" output.txt || { echo "ERROR: Features Per Compiler Demo not found"; exit 1; }
242-
grep -q "✓ DEBUG: -g flag found" output.txt || { echo "ERROR: Debug feature not detected"; exit 1; }
254+
grep -q "✓ DEBUG: debug flags found" output.txt || { echo "ERROR: Debug feature not detected"; exit 1; }
243255
grep -q "✓ All compiler flag checks PASSED" output.txt || { echo "ERROR: Expected all checks to pass"; exit 1; }
244256
# Should NOT have release or fast flags
245257
if grep -q "✓ RELEASE: -O flags found" output.txt; then
@@ -251,17 +263,20 @@ echo "✓ Debug feature works"
251263
# Test 19: Individual features - release only
252264
echo "Test 19: Features per compiler - release feature only"
253265
rm -rf build
254-
if "$fpm" run --features release > output.txt; then
266+
if "$fpm" run --features release > output.txt 2>&1; then
255267
echo "✓ Exit code 0 (success) as expected"
256268
else
257269
echo "ERROR: Expected exit code 0 but got non-zero exit code"
270+
echo "=== Program output ==="
271+
cat output.txt
272+
echo "======================"
258273
exit 1
259274
fi
260275
grep -q "Features Per Compiler Demo" output.txt || { echo "ERROR: Features Per Compiler Demo not found"; exit 1; }
261276
grep -q "✓ RELEASE: -O flags found" output.txt || { echo "ERROR: Release feature not detected"; exit 1; }
262277
grep -q "✓ All compiler flag checks PASSED" output.txt || { echo "ERROR: Expected all checks to pass"; exit 1; }
263278
# Should NOT have debug flags
264-
if grep -q "✓ DEBUG: -g flag found" output.txt; then
279+
if grep -q "✓ DEBUG: debug flags found" output.txt; then
265280
echo "ERROR: Debug flags should not be present with release only"
266281
exit 1
267282
fi
@@ -270,16 +285,19 @@ echo "✓ Release feature works"
270285
# Test 20: No profile/features - baseline
271286
echo "Test 20: Features per compiler - baseline (no profile)"
272287
rm -rf build
273-
if "$fpm" run > output.txt; then
288+
if "$fpm" run > output.txt 2>&1; then
274289
echo "✓ Exit code 0 (success) as expected"
275290
else
276291
echo "ERROR: Expected exit code 0 but got non-zero exit code"
292+
echo "=== Program output ==="
293+
cat output.txt
294+
echo "======================"
277295
exit 1
278296
fi
279297
grep -q "Features Per Compiler Demo" output.txt || { echo "ERROR: Features Per Compiler Demo not found"; exit 1; }
280298
grep -q "✓ All compiler flag checks PASSED" output.txt || { echo "ERROR: Expected all checks to pass"; exit 1; }
281299
# Should NOT have any feature flags in baseline
282-
if grep -q "✓ DEBUG: -g flag found" output.txt; then
300+
if grep -q "✓ DEBUG: debug flags found" output.txt; then
283301
echo "ERROR: Debug flags should not be present in baseline"
284302
exit 1
285303
fi

example_packages/features_per_compiler/app/main.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ program main
2525
print '(a)', ''
2626

2727
! Check for feature flags
28-
debug_active = index(options_str, '-g') > 0
28+
debug_active = index(options_str, ' -g ') > 0
2929
release_active = index(options_str, '-O3') > 0
3030
verbose_active = index(options_str, ' -v') > 0 .or. index(options_str, ' -v ') > 0
31-
fast_active = index(options_str, 'fast') > 0
31+
fast_active = index(options_str, 'fast') > 0
3232
strict_active = index(options_str, '-std=f2018') > 0 .or. index(options_str, '-stand f18') > 0
3333

3434
! Display active features
3535
print '(a)', 'Active features detected:'
36-
if (debug_active) print '(a)', ' ✓ DEBUG: -g flag found'
36+
if (debug_active) print '(a)', ' ✓ DEBUG: debug flags found'
3737
if (release_active) print '(a)', ' ✓ RELEASE: -O flags found'
3838
if (verbose_active) print '(a)', ' ✓ VERBOSE: -v flag found'
3939
if (fast_active) print '(a)', ' ✓ FAST: fast optimization flags found'

0 commit comments

Comments
 (0)