Skip to content

Commit

Permalink
Split Docker make targets
Browse files Browse the repository at this point in the history
add run tests script
  • Loading branch information
andystanton committed Nov 5, 2021
1 parent 6d1dc92 commit 289751c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY : all clean build runonly run docker
.PHONY : all clean build runonly run docker dockerbuild dockerclean

project_name = nasm-test
image_name = debasm
Expand All @@ -17,6 +17,11 @@ runonly:

run: | all runonly

docker:
dockerbuild:
@docker build -t $(image_name) --compress .;

docker: dockerbuild
@docker run --rm $(image_name);

dockerclean:
@docker rmi $(image_name);
34 changes: 34 additions & 0 deletions test/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

pushd $(dirname $0) >/dev/null
script_path=$PWD
parent_path=$(dirname $script_path)
popd >/dev/null

pushd ${parent_path} >/dev/null

echo "Building test environment..."

make dockerbuild

echo "Running tests..."

makefile_output=$(make docker 2>dev/null)

echo "Test results..."

exit_code=1
if [ $? = 0 ] && echo "$makefile_output" | egrep -q '^Hello world$'; then
printf "[\x1b[32m✔\x1b[0m] Test: Hello world\n"
exit_code=0
else
printf "[\x1b[31m✘\x1b[0m] Test: Hello world\n"
fi

echo "Cleaning up Docker image"

make dockerclean

popd >/dev/null

exit $exit_code

0 comments on commit 289751c

Please sign in to comment.