Skip to content

Allow SAFE_RUN to correctly run and check results #6128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions test/native-tests/test_native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ FIND_CLANG() {
}

SAFE_RUN() {
local SF_RETURN_VALUE=$($1 2>&1)
local SF_OUTPUT
SF_OUTPUT=$(eval "( $1 )" 2>&1)

if [[ $? != 0 ]]; then
>&2 echo $SF_RETURN_VALUE
>&2 echo "$SF_OUTPUT"
exit 1
fi
}
Expand All @@ -57,24 +58,24 @@ fi
RUN () {
TEST_PATH=$1
echo "Testing $TEST_PATH"
SAFE_RUN `cd $TEST_PATH; ${CH_DIR} Platform.js > Makefile`
SAFE_RUN "cd $TEST_PATH && ${CH_DIR} Platform.js > Makefile"
RES=$(cd $TEST_PATH; cat Makefile)

if [[ $RES =~ "# IGNORE_THIS_TEST" ]]; then
echo "Ignoring $TEST_PATH"
else
SAFE_RUN `cd $TEST_PATH; make CC=${CC} CXX=${CXX}`
SAFE_RUN "cd $TEST_PATH && make CC=${CC} CXX=${CXX}"
RES=$(cd $TEST_PATH; ./sample.o)
TEST "SUCCESS"
SAFE_RUN `cd $TEST_PATH; rm -rf ./sample.o`
SAFE_RUN "cd $TEST_PATH && rm -rf ./sample.o"
fi
}

RUN_CMD () {
TEST_PATH=$1
CMD=$2
echo "Testing $TEST_PATH"
SAFE_RUN `cd $TEST_PATH; $CMD`
SAFE_RUN "cd $TEST_PATH && $CMD"
}

# static lib tests
Expand All @@ -100,4 +101,4 @@ RUN "test-shared-basic"
# test python
RUN_CMD "test-python" "python helloWorld.py ${BUILD_TYPE}"

SAFE_RUN `rm -rf Makefile`
SAFE_RUN "rm -rf Makefile"