Skip to content

Commit befcb7f

Browse files
author
Oleg Sh
committed
Fixed script with ai.
1 parent d67a189 commit befcb7f

File tree

1 file changed

+47
-19
lines changed

1 file changed

+47
-19
lines changed

test/SalesmanProblem/_runTests.sh

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,59 @@
1-
# @echo off
2-
3-
isFaild=0;
4-
5-
rm *.test &>/dev/null
6-
7-
while IFS=$' ' read -r command xmlFile; do
1+
#!/bin/bash
2+
3+
# Initialize failure flag
4+
isFailed=0
5+
6+
# Remove old test output files
7+
rm -f *.test &>/dev/null
8+
9+
# Read each line from testList.txt
10+
while read -r line; do
11+
# Split the line into an array of arguments
12+
args=($line)
13+
14+
command="${args[0]}"
15+
xmlFile=""
16+
extraArgs=()
17+
18+
# Find the first argument ending with ".xml"
19+
for ((i=1; i<${#args[@]}; i++)); do
20+
if [[ "${args[i]}" == *.xml ]]; then
21+
xmlFile="${args[i]}"
22+
# Everything after the XML file is considered extra arguments
23+
extraArgs=("${args[@]:i+1}")
24+
break
25+
fi
26+
done
27+
28+
# If no XML file found, skip this line
29+
if [[ -z "$xmlFile" ]]; then
30+
echo "No XML file found in line: $line"
31+
continue
32+
fi
833

9-
if [ "$2" == "-debug" ]; then
10-
echo "$exePath ${command} ./${xmlFile} > ${xmlFile}.test"
34+
# Print debug information if "-debug" flag is passed as script argument
35+
if [[ "$2" == "-debug" ]]; then
36+
echo "$exePath $command ./$xmlFile ${extraArgs[*]} > ${xmlFile}.test"
1137
fi
1238

13-
$exePath ${command} ./${xmlFile} > ${xmlFile}.test
39+
# Execute the command and redirect output to a .test file
40+
$exePath "$command" "./$xmlFile" "${extraArgs[@]}" > "${xmlFile}.test"
1441

15-
if diff --ignore-all-space ${xmlFile}.res ${xmlFile}.test >/dev/null ; then
16-
continue;
42+
# Compare the result with the expected .res file
43+
if diff --ignore-all-space "${xmlFile}.res" "${xmlFile}.test" >/dev/null; then
44+
continue
1745
else
18-
isFaild=1;
46+
isFailed=1
1947
echo "${xmlFile} failed."
20-
break;
48+
break
2149
fi
2250
done < "testList.txt"
2351

24-
if [ $isFaild -eq 1 ]; then
25-
echo "Failed";
26-
exit 1;
52+
# Final status output
53+
if [ $isFailed -eq 1 ]; then
54+
echo "Failed"
55+
exit 1
2756
else
2857
echo "OK"
29-
rm *.test &>/dev/null
58+
rm -f *.test &>/dev/null
3059
fi
31-

0 commit comments

Comments
 (0)