@@ -21,84 +21,87 @@ pushd "features_demo"
21
21
echo " Test 1: Basic debug feature"
22
22
rm -rf build
23
23
" $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; }
26
25
echo " ✓ Debug feature works"
27
26
28
27
# Test 2: Profile usage - development profile (includes debug)
29
28
echo " Test 2: Development profile (debug feature)"
30
29
rm -rf build
31
30
" $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 ; }
33
32
echo " ✓ Development profile works"
34
33
35
34
# Test 3: Multiple features
36
35
echo " Test 3: Multiple features (debug + openmp)"
37
36
rm -rf build
38
37
" $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 ; }
41
40
echo " ✓ Multiple features work"
42
41
43
42
# Test 4: Feature-specific executable (debug_demo only available with debug feature)
44
43
echo " Test 4: Feature-specific executable"
45
44
rm -rf build
46
45
" $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 ; }
49
48
echo " ✓ Feature-specific executable works"
50
49
51
50
# Test 5: Profile with multiple features - production profile (release + openmp)
52
51
echo " Test 5: Production profile (release + openmp)"
53
52
rm -rf build
54
53
" $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 ; }
57
56
# 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
59
61
echo " ✓ Production profile works"
60
62
61
63
# Test 6: No features - baseline behavior
62
64
echo " Test 6: No features (baseline)"
63
65
rm -rf build
64
66
" $fpm " run --target features_demo | tee output.txt
65
67
# 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
69
80
echo " ✓ Baseline (no features) works"
70
81
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"
81
84
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"
84
87
else
85
88
echo " ERROR: Should reject invalid feature" && exit 1
86
89
fi
87
90
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"
90
93
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"
93
96
else
94
97
echo " ERROR: Should reject invalid profile" && exit 1
95
98
fi
96
99
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"
99
102
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"
102
105
else
103
106
echo " ERROR: Should reject features + profile combination" && exit 1
104
107
fi
@@ -112,45 +115,45 @@ echo "=== Testing features_with_dependency package ==="
112
115
# Test dependency features
113
116
pushd " features_with_dependency"
114
117
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"
117
120
rm -rf build
118
121
" $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 ; }
121
124
echo " ✓ Dependency package baseline works"
122
125
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"
125
128
rm -rf build
126
129
" $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 ; }
129
132
echo " ✓ Debug dependency feature works"
130
133
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"
133
136
rm -rf build
134
137
" $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 ; }
137
140
echo " ✓ Release dependency feature works"
138
141
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"
141
144
rm -rf build
142
145
" $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 ; }
146
149
echo " ✓ Multi dependency feature works"
147
150
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"
150
153
rm -rf build
151
154
" $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 ; }
154
157
echo " ✓ Debug dependency profile works"
155
158
156
159
# Cleanup
0 commit comments