mirror of
https://github.com/eza-community/eza.git
synced 2025-07-07 19:35:33 +00:00
fix: Support passing multiple options for generate-trycmd-test.sh
This commit is contained in:
parent
9681cb65b3
commit
d1702f0db1
1 changed files with 15 additions and 12 deletions
|
@ -2,39 +2,42 @@
|
||||||
|
|
||||||
# Generate test data for the program
|
# Generate test data for the program
|
||||||
|
|
||||||
if [ $# -ne 2 ]; then
|
if [ $# -le 1 ]; then
|
||||||
echo "Usage: $0 <test name> <test argument>"
|
echo "Usage: $0 <test name> <test argument>"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
test_name=$1
|
||||||
|
shift
|
||||||
|
|
||||||
# Clean up previous test data
|
# Clean up previous test data
|
||||||
|
|
||||||
if [ -f tests/cmd/"$1".toml ]; then
|
if [ -f tests/cmd/"$test_name".toml ]; then
|
||||||
rm tests/cmd/"$1".toml
|
rm tests/cmd/"$test_name".toml
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f tests/cmd/"$1".stdout ]; then
|
if [ -f tests/cmd/"$test_name".stdout ]; then
|
||||||
rm tests/cmd/"$1".stdout
|
rm tests/cmd/"$test_name".stdout
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f tests/cmd/"$1".stderr ]; then
|
if [ -f tests/cmd/"$test_name".stderr ]; then
|
||||||
rm tests/cmd/"$1".stderr
|
rm tests/cmd/"$test_name".stderr
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Generate test data
|
# Generate test data
|
||||||
|
|
||||||
touch tests/cmd/"$1".toml
|
touch tests/cmd/"$test_name".toml
|
||||||
|
|
||||||
echo 'bin.name = "eza"' >> tests/cmd/"$1".toml
|
echo 'bin.name = "eza"' >> tests/cmd/"$test_name".toml
|
||||||
echo 'args = "'"$2"'"' >> tests/cmd/"$1".toml
|
echo 'args = "'"$*"'"' >> tests/cmd/"$test_name".toml
|
||||||
|
|
||||||
# Generate expected output
|
# Generate expected output
|
||||||
|
|
||||||
if [ -f target/debug/eza ]; then
|
if [ -f target/debug/eza ]; then
|
||||||
target/debug/eza "$2" > tests/cmd/"$1".stdout 2> tests/cmd/"$1".stderr
|
target/debug/eza "$@" > tests/cmd/"$test_name".stdout 2> tests/cmd/"$test_name".stderr
|
||||||
returncode=$?
|
returncode=$?
|
||||||
if [ $returncode -ne 0 ]; then
|
if [ $returncode -ne 0 ]; then
|
||||||
echo -e 'status.code = '$returncode'' >> tests/cmd/"$1".toml
|
echo -e 'status.code = '$returncode'' >> tests/cmd/"$test_name".toml
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue