9595
9696# Test 2: Invalid option
9797invalid_output=$( " $PROJECT_ROOT /apply-md" --invalid-option 2>&1 )
98- if [ $? -ne 0 ] && echo " $invalid_output " | grep -q " Unknown parameter" ; then
98+ if ! " $PROJECT_ROOT /apply-md " --invalid-option > /dev/null 2>&1 && echo " $invalid_output " | grep -q " Unknown parameter" ; then
9999 echo " ok $(( test_number+= 1 )) - invalid option causes error"
100100else
101101 echo " not ok $(( test_number+= 1 )) - invalid option causes error"
105105fi
106106
107107# Test 3: Combined arguments
108- output=$( cd " $test_dir " && cat test_input.md | " $PROJECT_ROOT /apply-md" --dry-run --verbose 2>&1 )
108+ output=$( cd " $test_dir " && " $PROJECT_ROOT /apply-md" --dry-run --verbose < test_input.md 2>&1 )
109109if echo " $output " | grep -q " DRY RUN" && echo " $output " | grep -q " Starting markdown code application" ; then
110110 echo " ok $(( test_number+= 1 )) - combined arguments work correctly"
111111else
@@ -122,7 +122,7 @@ echo "Original content" > "$test_dir/file1.txt"
122122echo " Original content" > " $test_dir /file2.txt"
123123
124124# Test 4: Basic file update
125- if cd " $test_dir " && cat test_input.md | " $PROJECT_ROOT /apply-md" && grep -q " Updated content" test_file.txt; then
125+ if cd " $test_dir " && " $PROJECT_ROOT /apply-md" < test_input.md && grep -q " Updated content" test_file.txt; then
126126 echo " ok $(( test_number+= 1 )) - basic file update"
127127else
128128 echo " not ok $(( test_number+= 1 )) - basic file update"
132132
133133# Test 5: Dry run mode
134134echo " Original content" > " $test_dir /test_file.txt"
135- output=$( cd " $test_dir " && cat test_input.md | " $PROJECT_ROOT /apply-md" --dry-run 2>&1 )
135+ output=$( cd " $test_dir " && " $PROJECT_ROOT /apply-md" --dry-run < test_input.md 2>&1 )
136136if grep -q " Original content" " $test_dir /test_file.txt" && echo " $output " | grep -q " Would update file" ; then
137137 echo " ok $(( test_number+= 1 )) - dry run mode"
138138else
143143fi
144144
145145# Test 6: Verbose mode
146- output=$( cd " $test_dir " && cat test_input.md | " $PROJECT_ROOT /apply-md" --verbose 2>&1 )
146+ output=$( cd " $test_dir " && " $PROJECT_ROOT /apply-md" --verbose < test_input.md 2>&1 )
147147if echo " $output " | grep -q " Starting markdown code application" ; then
148148 echo " ok $(( test_number+= 1 )) - verbose mode"
149149else
156156echo " # Section 3: Create Missing Files Tests"
157157
158158# Test 7: Without create-missing flag
159- output=$( cd " $test_dir " && cat missing_files.md | " $PROJECT_ROOT /apply-md" 2>&1 )
159+ output=$( cd " $test_dir " && " $PROJECT_ROOT /apply-md" < missing_files.md 2>&1 )
160160if [ ! -f " $test_dir /new_file.txt" ] && echo " $output " | grep -q " Warning: File does not exist" ; then
161161 echo " ok $(( test_number+= 1 )) - without create-missing flag"
162162else
167167fi
168168
169169# Test 8: With create-missing flag
170- output=$( cd " $test_dir " && cat missing_files.md | " $PROJECT_ROOT /apply-md" --create-missing 2>&1 )
170+ output=$( cd " $test_dir " && " $PROJECT_ROOT /apply-md" --create-missing < missing_files.md 2>&1 )
171171if [ -f " $test_dir /new_file.txt" ] && [ -f " $test_dir /src/new_folder/script.js" ]; then
172172 echo " ok $(( test_number+= 1 )) - with create-missing flag"
173173else
180180echo " # Section 4: Multiple Blocks Tests"
181181
182182# Test 9: Multiple file updates
183- output=$( cd " $test_dir " && cat multiple_blocks.md | " $PROJECT_ROOT /apply-md" --create-missing 2>&1 )
183+ output=$( cd " $test_dir " && " $PROJECT_ROOT /apply-md" --create-missing < multiple_blocks.md 2>&1 )
184184if grep -q " Updated content 1" " $test_dir /file1.txt" && grep -q " Updated content 2" " $test_dir /file2.txt" ; then
185185 echo " ok $(( test_number+= 1 )) - multiple file updates"
186186else
@@ -205,4 +205,4 @@ echo "# Tests completed, cleaning up"
205205cleanup_test_dir " $test_dir "
206206
207207# Exit with success if all tests passed
208- exit $failures
208+ exit $failures
0 commit comments