Skip to content

Commit

Permalink
shellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
tyfkda committed Sep 8, 2023
1 parent 18cdffe commit 56b22d1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 24 deletions.
9 changes: 5 additions & 4 deletions tests/cpptest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -o pipefail

source ./test_sub.sh

AOUT=${AOUT:-$(basename `mktemp -u`)}
AOUT=${AOUT:-$(basename "$(mktemp -u)")}
CPP=${CPP:-../cpp}
XCC=${XCC:-../xcc}
RUN_AOUT=${RUN_AOUT:-./"$AOUT"}
Expand Down Expand Up @@ -126,15 +126,16 @@ test_misc() {
test_cat() {
begin_test_suite "Concat"

local CATDEFS=`cat <<EOS
local CATDEFS
CATDEFS=$(cat <<EOS
#define CAT(x, y) x ## y
#define INDIRECT(x, y) CAT(x, y)
#define N 1
#define FOO1 MATCHED
#define X Y
#define _ /* empty */
EOS
`
)
try 'simple' 'ABCDEF' "$CATDEFS\nCAT(ABC, DEF)"
try 'non-sym' '123UL' "$CATDEFS\nCAT(123, UL)"
try 'non-sym2' '123.f' "$CATDEFS\nCAT(123, .f)"
Expand Down Expand Up @@ -205,5 +206,5 @@ test_error
test_run

if [[ $FAILED_SUITE_COUNT -ne 0 ]]; then
exit $FAILED_SUITE_COUNT
exit "$FAILED_SUITE_COUNT"
fi
6 changes: 3 additions & 3 deletions tests/example_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source ./test_sub.sh

AOUT=${AOUT:-$(basename `mktemp -u`)}
AOUT=${AOUT:-$(basename "$(mktemp -u)")}
XCC=${XCC:-../xcc}

try() {
Expand Down Expand Up @@ -63,7 +63,7 @@ test_all() {
try 'fib' 832040 ../examples/fib.c
try 'echo' 'foo bar baz' ../examples/echo.c foo bar baz

if [ "`no_flonum`" != "true" ]; then
if [ "$(no_flonum)" != "true" ]; then
try_cmp 'mandelbrot' 'mandel256.ppm' 'mandelbrot.ppm' ../examples/mandelbrot.c 100 256 256
fi

Expand All @@ -73,5 +73,5 @@ test_all() {
test_all

if [[ $FAILED_SUITE_COUNT -ne 0 ]]; then
exit $FAILED_SUITE_COUNT
exit "$FAILED_SUITE_COUNT"
fi
10 changes: 5 additions & 5 deletions tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

source ./test_sub.sh

AOUT=${AOUT:-$(basename `mktemp -u`)}
AOUT=${AOUT:-$(basename "$(mktemp -u)")}
XCC=${XCC:-../xcc}
RUN_AOUT=${RUN_AOUT:-./"$AOUT"}

echo Compile=[$XCC], Run=[$RUN_AOUT]
echo "Compile=[$XCC], Run=[$RUN_AOUT]"

ARCH=$(arch)
if [[ -z "$RE_SKIP" ]]; then
Expand Down Expand Up @@ -38,7 +38,7 @@ try_direct() {
local OPT=''
echo -n "$input" | grep "$RE_WNOERR" > /dev/null || OPT=-Werror

echo -e "$input" | eval $XCC $OPT -o "$AOUT" -xc - $SILENT || {
echo -e "$input" | eval "$XCC" $OPT -o "$AOUT" -xc - "$SILENT" || {
end_test 'Compile failed'
return
}
Expand Down Expand Up @@ -69,7 +69,7 @@ compile_error() {
local OPT=''
echo -n "$input" | grep "$RE_WNOERR" > /dev/null || OPT=-Werror

echo -e "$input" | eval $XCC $OPT -o "$AOUT" -xc - $SILENT
echo -e "$input" | eval "$XCC" $OPT -o "$AOUT" -xc - "$SILENT"
local exitcode="$?"

local err=''; [[ "$exitcode" -ne 0 ]] || err="Compile error expected, but succeeded"
Expand Down Expand Up @@ -263,5 +263,5 @@ test_function
test_error

if [[ $FAILED_SUITE_COUNT -ne 0 ]]; then
exit $FAILED_SUITE_COUNT
exit "$FAILED_SUITE_COUNT"
fi
10 changes: 5 additions & 5 deletions tests/test_sub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ begin_test_suite() {

end_test_suite() {
if [[ $ERROR_COUNT -eq 0 ]]; then
printf "${CLEAR_LINE} ${SUITE_NAME}: ${GREEN}OK: ${TEST_COUNT}${RESET_COLOR}\n"
echo "${CLEAR_LINE} ${SUITE_NAME}: ${GREEN}OK: ${TEST_COUNT}${RESET_COLOR}"
else
printf "${CLEAR_LINE} ${RED}${BOLD}ERROR: ${ERROR_COUNT}/${TEST_COUNT}${RESET_COLOR}\n"
FAILED_SUITE_COUNT=$(($FAILED_SUITE_COUNT + 1))
echo "${CLEAR_LINE} ${RED}${BOLD}ERROR: ${ERROR_COUNT}/${TEST_COUNT}${RESET_COLOR}"
FAILED_SUITE_COUNT=$((FAILED_SUITE_COUNT + 1))
fi
}

begin_test() {
local title="$1"
TEST_COUNT=$(($TEST_COUNT + 1))
TEST_COUNT=$((TEST_COUNT + 1))
printf "${CLEAR_LINE} ${SUITE_NAME} ${TEST_COUNT}: $title"
}

end_test() {
local err="$1"
if [[ "$err" != "" ]]; then
printf " ${RED}${BOLD}FAILED${RESET_COLOR}: ${err}\n"
ERROR_COUNT=$(($ERROR_COUNT + 1))
ERROR_COUNT=$((ERROR_COUNT + 1))
fi
}
14 changes: 7 additions & 7 deletions tool/run-gen2wcc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

set -e

PRJROOT=$(cd $(dirname $0)/..;pwd)
PRJROOT=$(cd "$(dirname "$0")/..";pwd)
WCCWASM=$PRJROOT/cc.wasm

if [ ! -e $WCCWASM ]; then
if [ ! -e "$WCCWASM" ]; then
echo "Run 'make wcc-gen2' command to create executable" 1>&2
exit 1
fi

npx node $PRJROOT/tool/runwasi.js \
npx node "$PRJROOT/tool/runwasi.js" \
--dir=. \
--dir=/tmp \
--mapdir=/usr/include::$PRJROOT/include \
--mapdir=/usr/lib::$PRJROOT/libsrc/_wasm \
--mapdir=/usr/local/include::$PRJROOT/libsrc \
$WCCWASM -- $@
"--mapdir=/usr/include::$PRJROOT/include" \
"--mapdir=/usr/lib::$PRJROOT/libsrc/_wasm" \
"--mapdir=/usr/local/include::$PRJROOT/libsrc" \
"$WCCWASM" -- "$@"

0 comments on commit 56b22d1

Please sign in to comment.