From 8435028a5500e40ae295eb717dcd3af0f97ca793 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 12 Apr 2020 15:24:38 -0400 Subject: [PATCH] Dockerized tests are now working and added a flag to toggle showing the test case diff. --- Dockerfile | 6 +++++- js/run_compliance_suite.bash | 25 +++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index c20368c..b700cce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,8 @@ FROM rustlang/rust:nightly-alpine3.10 -RUN apk --no-cache add bash git npm nodejs +# findutils needed to replace busybox xargs because it is failing to +# pass stdin through when using the `-a` flag +RUN apk --no-cache add bash git npm nodejs findutils # Create unprivileged user RUN addgroup -S duster && adduser -S duster -G duster @@ -20,3 +22,5 @@ RUN chown -R duster:duster /home/duster/duster USER duster RUN git clean -dfxq RUN cargo build +RUN npm link dustjs-linkedin +CMD /home/duster/duster/js/run_compliance_suite.bash diff --git a/js/run_compliance_suite.bash b/js/run_compliance_suite.bash index aaa94d6..7788521 100755 --- a/js/run_compliance_suite.bash +++ b/js/run_compliance_suite.bash @@ -6,6 +6,25 @@ IFS=$'\n\t' DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" failed_count=0 +show_diff=0 + +while (( "$#" )); do + if [ "$1" = "--help" ]; then + cat<&2 echo "Unrecognized option: $1") + exit 1 + fi + shift +done while read -r test_group; do test_group_name=$(basename "$test_group") @@ -14,11 +33,13 @@ while read -r test_group; do test_case_name=${test_case_file_name%.*} set +e ( - if cmp --quiet <(xargs -a <(find "$test_group" -maxdepth 1 -mindepth 1 -type f -name 'main.dust'; find "$test_group" -maxdepth 1 -mindepth 1 -type f -name '*.dust' ! -name 'main.dust') node "$DIR/dustjs_shim.js" < "$test_case") <(xargs -a <(find "$test_group" -maxdepth 1 -mindepth 1 -type f -name 'main.dust'; find "$test_group" -maxdepth 1 -mindepth 1 -type f -name '*.dust' ! -name 'main.dust') "$DIR/../target/debug/duster-cli" < "$test_case"); then + if cmp -s <(xargs -a <(find "$test_group" -maxdepth 1 -mindepth 1 -type f -name 'main.dust'; find "$test_group" -maxdepth 1 -mindepth 1 -type f -name '*.dust' ! -name 'main.dust') node "$DIR/dustjs_shim.js" < "$test_case") <(xargs -a <(find "$test_group" -maxdepth 1 -mindepth 1 -type f -name 'main.dust'; find "$test_group" -maxdepth 1 -mindepth 1 -type f -name '*.dust' ! -name 'main.dust') "$DIR/../target/debug/duster-cli" < "$test_case"); then echo "$test_group_name::$test_case_name PASSED" else echo "$test_group_name::$test_case_name FAILED" - diff <(xargs -a <(find "$test_group" -maxdepth 1 -mindepth 1 -type f -name 'main.dust'; find "$test_group" -maxdepth 1 -mindepth 1 -type f -name '*.dust' ! -name 'main.dust') node "$DIR/dustjs_shim.js" < "$test_case") <(xargs -a <(find "$test_group" -maxdepth 1 -mindepth 1 -type f -name 'main.dust'; find "$test_group" -maxdepth 1 -mindepth 1 -type f -name '*.dust' ! -name 'main.dust') "$DIR/../target/debug/duster-cli" < "$test_case") + if [ $show_diff -eq 1 ]; then + diff --label "dustjs-linked" --label "duster" <(xargs -a <(find "$test_group" -maxdepth 1 -mindepth 1 -type f -name 'main.dust'; find "$test_group" -maxdepth 1 -mindepth 1 -type f -name '*.dust' ! -name 'main.dust') node "$DIR/dustjs_shim.js" < "$test_case") <(xargs -a <(find "$test_group" -maxdepth 1 -mindepth 1 -type f -name 'main.dust'; find "$test_group" -maxdepth 1 -mindepth 1 -type f -name '*.dust' ! -name 'main.dust') "$DIR/../target/debug/duster-cli" < "$test_case") + fi exit 1 fi )