Skip to content

Commit f47ab04

Browse files
committed
Added local docker tests for centos, ubuntu, fedora
1 parent d048b9b commit f47ab04

File tree

6 files changed

+55
-1
lines changed

6 files changed

+55
-1
lines changed

JSONPath.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ sanity_checks() {
8484
# Reset some vars
8585
for binary in gawk grep sed; do
8686
if ! which $binary >& /dev/null; then
87-
echo "$UNKNOWN: $binary binary not found in path. Aborting."
87+
echo "ERROR: $binary binary not found in path. Aborting."
8888
exit 1
8989
fi
9090
done

all-docker-tests.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
log=testlog.log
2+
3+
# Fedora
4+
export IMAGE=json-path-fedora-bash
5+
cp test/docker/Dockerfile-fedora test/docker/Dockerfile
6+
./test/docker/wrap_in_docker.sh ./all-tests.sh | tee $log
7+
8+
a=$(grep 'test(s) failed' $log)
9+
10+
# Ubuntu
11+
export IMAGE=json-path-ubuntu-bash
12+
cp test/docker/Dockerfile-ubuntu test/docker/Dockerfile
13+
./test/docker/wrap_in_docker.sh ./all-tests.sh | tee $log
14+
15+
b=$(grep 'test(s) failed' $log)
16+
17+
# Centos
18+
export IMAGE=json-path-centos-bash
19+
cp test/docker/Dockerfile-centos test/docker/Dockerfile
20+
./test/docker/wrap_in_docker.sh ./all-tests.sh | tee $log
21+
22+
c=$(grep 'test(s) failed' $log)
23+
24+
rm $log
25+
26+
echo
27+
echo "Fedora tests"
28+
echo $a
29+
echo "Ubuntu tests"
30+
echo $b
31+
echo "Centos tests"
32+
echo $c

test/docker/Dockerfile-centos

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM centos
2+
3+
RUN yum -y install python2 diffutils which

test/docker/Dockerfile-fedora

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM fedora
2+
3+
RUN dnf -y install python diffutils which

test/docker/Dockerfile-ubuntu

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM ubuntu
2+
3+
RUN apt-get update && apt-get -y install python gawk

test/docker/wrap_in_docker.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
IMAGE=${IMAGE:-json-path-bash}
5+
6+
readonly script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
7+
readonly RUN_ARGS="$@"
8+
readonly target_image=$IMAGE
9+
10+
docker build -t "$target_image" "$script_dir"
11+
12+
docker run --rm -v "$(pwd):/localdir" -i "$target_image" sh -c "cd /localdir && $RUN_ARGS"
13+

0 commit comments

Comments
 (0)