-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test-backend.sh
executable file
·35 lines (31 loc) · 1.04 KB
/
test-backend.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env bash
# Test the Camisole backend for https://github.com/Naereen/Peut-on-coder-avec-OCaml-Python-et-C-par-SMS
# For all the ./json_tests/LANGUAGE/*.json files, the expected output is ONE line printing 42
#
# TODO: automatically produce the .json files if it's not present? flemme
#
# Author: Lilian BESSON
# Email: lilian DOT besson AT crans D O T org
# Version: 1
# Date: 19-02-2021
# Web: https://github.com/Naereen/Peut-on-coder-avec-OCaml-Python-et-C-par-SMS.git
#
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
URL="${1%/}"
FOLDER="${2%/}"
echo -e "\n\nReading JSON files from folder '${FOLDER}':"
for f in "$FOLDER"/*.json; do
echo -e "\nLoad JSON file '${f}':"
echo curl --silent \
-X POST -H "Content-Type: application/json" \
--data @"${f}" \
"${URL}/run"
curl --silent \
-X POST -H "Content-Type: application/json" \
--data @"${f}" \
"${URL}/run" \
| python -m json.tool \
| grep -o '"stdout": "42\(\\n\)\?"'
# | cat
done