|
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 |
8 | 33 |
|
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" |
11 | 37 | fi |
12 | 38 |
|
13 | | - $exePath ${command} ./${xmlFile} > ${xmlFile}.test |
| 39 | + # Execute the command and redirect output to a .test file |
| 40 | + $exePath "$command" "./$xmlFile" "${extraArgs[@]}" > "${xmlFile}.test" |
14 | 41 |
|
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 |
17 | 45 | else |
18 | | - isFaild=1; |
| 46 | + isFailed=1 |
19 | 47 | echo "${xmlFile} failed." |
20 | | - break; |
| 48 | + break |
21 | 49 | fi |
22 | 50 | done < "testList.txt" |
23 | 51 |
|
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 |
27 | 56 | else |
28 | 57 | echo "OK" |
29 | | - rm *.test &>/dev/null |
| 58 | + rm -f *.test &>/dev/null |
30 | 59 | fi |
31 | | - |
|
0 commit comments