test script

This commit is contained in:
Thomas Hobson 2021-04-24 19:35:14 +12:00
parent aeda95a215
commit c6e78fa073
No known key found for this signature in database
GPG Key ID: 9F1FD9D87950DB6F
1 changed files with 20 additions and 0 deletions

20
packages/test.sh Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env bash
AUTH_HEADER="Authorization: $API_KEY"
for test_file in */*/test.*
do
IFS='/' read -ra test_parts <<< "$test_file"
language=${test_parts[0]}
lang_ver=${test_parts[1]}
test_src=$(python3 -c "import json; print(json.dumps(open('$test_file').read()))")
json='{"language":"'$language'","version":"'$lang_ver'","files":[{"content":'$test_src'}]}'
result=$(curl -s -XPOST -H "Content-Type: application/json" -d "$json" https://emkc.org/api/v2/piston/execute -H $AUTH_HEADER)
echo "==$test_file: $language-$lang_ver=="
#jq '.' <<<"$result"
jq -r '.compile.output + .run.output' <<<$result
done