Skip to content

Commit 9ec4ebb

Browse files
committed
fix most tests
1 parent ca94a39 commit 9ec4ebb

File tree

2 files changed

+57
-56
lines changed

2 files changed

+57
-56
lines changed

ci/test_features.sh

Lines changed: 57 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -21,84 +21,87 @@ pushd "features_demo"
2121
echo "Test 1: Basic debug feature"
2222
rm -rf build
2323
"$fpm" run --features debug | tee output.txt
24-
grep -q "DEBUG mode enabled" output.txt
25-
grep -q "✓ DEBUG mode enabled" output.txt
24+
grep -q "DEBUG mode enabled" output.txt || { echo "ERROR: DEBUG mode not enabled"; exit 1; }
2625
echo "✓ Debug feature works"
2726

2827
# Test 2: Profile usage - development profile (includes debug)
2928
echo "Test 2: Development profile (debug feature)"
3029
rm -rf build
3130
"$fpm" run --profile development --target features_demo | tee output.txt
32-
grep -q "DEBUG mode enabled" output.txt
31+
grep -q "DEBUG mode enabled" output.txt || { echo "ERROR: DEBUG mode not enabled in development profile"; exit 1; }
3332
echo "✓ Development profile works"
3433

3534
# Test 3: Multiple features
3635
echo "Test 3: Multiple features (debug + openmp)"
3736
rm -rf build
3837
"$fpm" run --features debug,openmp --target features_demo | tee output.txt
39-
grep -q "DEBUG mode enabled" output.txt
40-
grep -q "OpenMP support enabled" output.txt
38+
grep -q "DEBUG mode enabled" output.txt || { echo "ERROR: DEBUG mode not enabled with multiple features"; exit 1; }
39+
grep -q "OpenMP support enabled" output.txt || { echo "ERROR: OpenMP not enabled with multiple features"; exit 1; }
4140
echo "✓ Multiple features work"
4241

4342
# Test 4: Feature-specific executable (debug_demo only available with debug feature)
4443
echo "Test 4: Feature-specific executable"
4544
rm -rf build
4645
"$fpm" run --features debug --target debug_demo | tee output.txt
47-
grep -q "Debug Demo Program" output.txt
48-
grep -q "Debug mode: ON" output.txt
46+
grep -q "Debug Demo Program" output.txt || { echo "ERROR: Debug Demo Program not found"; exit 1; }
47+
grep -q "Debug mode: ON" output.txt || { echo "ERROR: Debug mode not ON in debug_demo"; exit 1; }
4948
echo "✓ Feature-specific executable works"
5049

5150
# Test 5: Profile with multiple features - production profile (release + openmp)
5251
echo "Test 5: Production profile (release + openmp)"
5352
rm -rf build
5453
"$fpm" run --profile production --target features_demo | tee output.txt
55-
grep -q "RELEASE mode enabled" output.txt
56-
grep -q "OpenMP support enabled" output.txt
54+
grep -q "RELEASE mode enabled" output.txt || { echo "ERROR: RELEASE mode not enabled in production profile"; exit 1; }
55+
grep -q "OpenMP support enabled" output.txt || { echo "ERROR: OpenMP not enabled in production profile"; exit 1; }
5756
# Should NOT have debug
58-
! grep -q "DEBUG mode enabled" output.txt
57+
if grep -q "DEBUG mode enabled" output.txt; then
58+
echo "ERROR: DEBUG mode should not be enabled in production profile"
59+
exit 1
60+
fi
5961
echo "✓ Production profile works"
6062

6163
# Test 6: No features - baseline behavior
6264
echo "Test 6: No features (baseline)"
6365
rm -rf build
6466
"$fpm" run --target features_demo | tee output.txt
6567
# Should have neither DEBUG nor RELEASE without explicit features
66-
! grep -q "DEBUG mode enabled" output.txt || true
67-
! grep -q "RELEASE mode enabled" output.txt || true
68-
grep -q "Features: NONE" output.txt || grep -q "Demo completed successfully" output.txt
68+
if grep -q "DEBUG mode enabled" output.txt; then
69+
echo "ERROR: DEBUG mode should not be enabled in baseline"
70+
exit 1
71+
fi
72+
if grep -q "RELEASE mode enabled" output.txt; then
73+
echo "ERROR: RELEASE mode should not be enabled in baseline"
74+
exit 1
75+
fi
76+
if ! grep -q "Features: NONE" output.txt && ! grep -q "Demo completed successfully" output.txt; then
77+
echo "ERROR: Expected baseline features output not found"
78+
exit 1
79+
fi
6980
echo "✓ Baseline (no features) works"
7081

71-
# Test 7: Build listing with features
72-
echo "Test 7: Build listing with features"
73-
rm -rf build
74-
"$fpm" build --features debug --list | tee build_list.txt
75-
grep -q "debug_demo" build_list.txt
76-
grep -q "features_demo" build_list.txt
77-
echo "✓ Build listing with features works"
78-
79-
# Test 8: Error handling - invalid feature
80-
echo "Test 8: Error handling for invalid feature"
82+
# Test 7: Error handling - invalid feature
83+
echo "Test 7: Error handling for invalid feature"
8184
rm -rf build
82-
if "$fpm" run --features nonexistent --target features_demo 2>&1 | grep -q "undefined feature"; then
83-
echo "Correctly rejected invalid feature"
85+
if ! "$fpm" run --features nonexistent --target features_demo > /dev/null 2>&1; then
86+
echo "Correctly rejected invalid feature"
8487
else
8588
echo "ERROR: Should reject invalid feature" && exit 1
8689
fi
8790

88-
# Test 9: Error handling - invalid profile
89-
echo "Test 9: Error handling for invalid profile"
91+
# Test 8: Error handling - invalid profile
92+
echo "Test 8: Error handling for invalid profile"
9093
rm -rf build
91-
if "$fpm" run --profile nonexistent --target features_demo 2>&1 | grep -q "undefined profile"; then
92-
echo "Correctly rejected invalid profile"
94+
if ! "$fpm" run --profile nonexistent --target features_demo > /dev/null 2>&1; then
95+
echo "Correctly rejected invalid profile"
9396
else
9497
echo "ERROR: Should reject invalid profile" && exit 1
9598
fi
9699

97-
# Test 10: Features and profile mutual exclusion
98-
echo "Test 10: Features and profile mutual exclusion"
100+
# Test 9: Features and profile mutual exclusion
101+
echo "Test 9: Features and profile mutual exclusion"
99102
rm -rf build
100-
if "$fpm" run --features debug --profile development --target features_demo 2>&1 | grep -q "cannot specify both"; then
101-
echo "Correctly rejected features + profile combination"
103+
if ! "$fpm" run --features debug --profile development --target features_demo > /dev/null 2>&1; then
104+
echo "Correctly rejected features + profile combination"
102105
else
103106
echo "ERROR: Should reject features + profile combination" && exit 1
104107
fi
@@ -112,45 +115,45 @@ echo "=== Testing features_with_dependency package ==="
112115
# Test dependency features
113116
pushd "features_with_dependency"
114117

115-
# Test 11: No features - should show NONE for both local and dependency
116-
echo "Test 11: Dependency package without features"
118+
# Test 10: No features - should show NONE for both local and dependency
119+
echo "Test 10: Dependency package without features"
117120
rm -rf build
118121
"$fpm" run | tee output.txt
119-
grep -q "NONE - no local features active" output.txt
120-
grep -q "Features: NONE" output.txt
122+
grep -q "NONE - no local features active" output.txt || { echo "ERROR: Local features NONE message not found"; exit 1; }
123+
grep -q "Features: NONE" output.txt || { echo "ERROR: Features NONE not found in dependency test"; exit 1; }
121124
echo "✓ Dependency package baseline works"
122125

123-
# Test 12: Debug dependency feature
124-
echo "Test 12: Debug dependency feature"
126+
# Test 11: Debug dependency feature
127+
echo "Test 11: Debug dependency feature"
125128
rm -rf build
126129
"$fpm" run --features with_feat_debug | tee output.txt
127-
grep -q "WITH_DEBUG_DEPENDENCY" output.txt
128-
grep -q "DEBUG mode enabled" output.txt
130+
grep -q "WITH_DEBUG_DEPENDENCY" output.txt || { echo "ERROR: WITH_DEBUG_DEPENDENCY not found"; exit 1; }
131+
grep -q "DEBUG mode enabled" output.txt || { echo "ERROR: DEBUG mode not enabled in dependency test"; exit 1; }
129132
echo "✓ Debug dependency feature works"
130133

131-
# Test 13: Release dependency feature
132-
echo "Test 13: Release dependency feature"
134+
# Test 12: Release dependency feature
135+
echo "Test 12: Release dependency feature"
133136
rm -rf build
134137
"$fpm" run --features with_feat_release | tee output.txt
135-
grep -q "WITH_RELEASE_DEPENDENCY" output.txt
136-
grep -q "RELEASE mode enabled" output.txt
138+
grep -q "WITH_RELEASE_DEPENDENCY" output.txt || { echo "ERROR: WITH_RELEASE_DEPENDENCY not found"; exit 1; }
139+
grep -q "RELEASE mode enabled" output.txt || { echo "ERROR: RELEASE mode not enabled in dependency test"; exit 1; }
137140
echo "✓ Release dependency feature works"
138141

139-
# Test 14: Multi dependency feature
140-
echo "Test 14: Multi dependency feature"
142+
# Test 13: Multi dependency feature
143+
echo "Test 13: Multi dependency feature"
141144
rm -rf build
142145
"$fpm" run --features with_feat_multi | tee output.txt
143-
grep -q "WITH_MULTI_DEPENDENCY" output.txt
144-
grep -q "DEBUG mode enabled" output.txt
145-
grep -q "MPI support enabled" output.txt
146+
grep -q "WITH_MULTI_DEPENDENCY" output.txt || { echo "ERROR: WITH_MULTI_DEPENDENCY not found"; exit 1; }
147+
grep -q "DEBUG mode enabled" output.txt || { echo "ERROR: DEBUG mode not enabled in multi dependency test"; exit 1; }
148+
grep -q "MPI support enabled" output.txt || { echo "ERROR: MPI support not enabled in multi dependency test"; exit 1; }
146149
echo "✓ Multi dependency feature works"
147150

148-
# Test 15: Profile with dependency features
149-
echo "Test 15: Debug dependency profile"
151+
# Test 14: Profile with dependency features
152+
echo "Test 14: Debug dependency profile"
150153
rm -rf build
151154
"$fpm" run --profile debug_dep | tee output.txt
152-
grep -q "WITH_DEBUG_DEPENDENCY" output.txt
153-
grep -q "DEBUG mode enabled" output.txt
155+
grep -q "WITH_DEBUG_DEPENDENCY" output.txt || { echo "ERROR: WITH_DEBUG_DEPENDENCY not found in profile test"; exit 1; }
156+
grep -q "DEBUG mode enabled" output.txt || { echo "ERROR: DEBUG mode not enabled in dependency profile test"; exit 1; }
154157
echo "✓ Debug dependency profile works"
155158

156159
# Cleanup

src/fpm/manifest/package.f90

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,6 @@ type(package_config_t) function export_config(self, platform, features, profile,
612612
return
613613
end if
614614

615-
print *, 'merge feature ',want_features(i)%s,' into ',cfg%name
616-
617615
! Add it to the current configuration
618616
call self%features(idx)%merge_into_package(cfg, platform, error)
619617
if (allocated(error)) return

0 commit comments

Comments
 (0)