mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-05 14:02:21 +00:00
29 lines
730 B
Bash
Executable File
29 lines
730 B
Bash
Executable File
#!/bin/bash
|
|
|
|
if [ -z "$1" ]; then
|
|
echo "Helper script to create empty test and reference files and assign a new number."
|
|
echo "Usage: $0 <base_test_name>"
|
|
exit 1
|
|
fi
|
|
|
|
TESTS_PATH=$(dirname ${BASH_SOURCE[0]})
|
|
set -ue
|
|
|
|
# shellcheck disable=SC2010
|
|
LAST_TEST_NO=$(ls -1 ${TESTS_PATH} | grep -P -o '^\d+' | sort -nr | head -1)
|
|
|
|
# remove leading zeros, increment and add padding zeros to 5 digits
|
|
NEW_TEST_NO=$(printf "%05d\n" $((10#$LAST_TEST_NO + 1)))
|
|
|
|
# if extension is not provided, use `.sql`
|
|
FILENAME="${1}"
|
|
FILEEXT="sql"
|
|
if [[ $1 == *.* ]] ; then
|
|
FILENAME="${1%.*}"
|
|
FILEEXT="${1##*.}"
|
|
fi
|
|
|
|
set -x
|
|
touch ${TESTS_PATH}/${NEW_TEST_NO}_${FILENAME}.${FILEEXT}
|
|
touch ${TESTS_PATH}/${NEW_TEST_NO}_${FILENAME}.reference
|