Skip to content

Commit

Permalink
test: add smoketests
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Gammon <[email protected]>
  • Loading branch information
sgammon committed Mar 11, 2024
1 parent c8262d0 commit 7afcd3f
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

## JPMS Attic: GitHub Configurations

Holds GitHub workflows and other repository documentation and configuration files.

8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ endif

include tools/common.mk

all: setup $(DEPS) repository samples ## Build all targets and setup the repository.
all: setup $(DEPS) repository samples test ## Build all targets and setup the repository.

setup: ## Setup local codebase features; performs first-run stuff.
$(info Building JPMS libraries...)
Expand Down Expand Up @@ -160,8 +160,12 @@ samples: ## Build samples.
$(info Building samples...)
$(RULE)$(MAKE) -C samples

test: ## Build and run integration and smoke tests.
$(info Running local testsuite...)
$(RULE)$(MAKE) -C tests PROJECT=$(PROJECT) LIBS=$(LIBS)

help: ## Show this help text ('make help').
$(info JPMS Attic:)
@grep -E '^[a-z1-9A-Z_-]+:.*?## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: all repository samples $(DEPS)
.PHONY: all repository samples test $(DEPS)
13 changes: 13 additions & 0 deletions tests/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#
# JPMS Attic: Tests
#

include ../tools/common.mk

all: smoke-tests integration-tests

smoke-tests:
$(RULE)$(MAKE) -C smoke PROJECT=$(PROJECT) LIBS=$(LIBS)

integration-tests:
$(RULE)$(MAKE) -C integration PROJECT=$(PROJECT) LIBS=$(LIBS)
5 changes: 5 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# JPMS Attic Tests

This repository holds integration and smoke tests for use of JPMS with Guava and other major JVM libraries. The [**integration tests**](./integration) hold projects which depend on Guava downstream. They are built with the JPMS version to ensure compatibility; the build itself is the test.

The [**smoke tests**](./smoke) are simple tests against the JARs provided by this repository.
11 changes: 11 additions & 0 deletions tests/integration/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# JPMS Attic: Integration Tests
#

include ../../tools/common.mk

all: integration-tests

integration-tests:
$(info Running integration tests...)
@echo "Integration tests would run"
Empty file added tests/integration/README.md
Empty file.
14 changes: 14 additions & 0 deletions tests/smoke/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# JPMS Attic: Smoke Tests
#

include ../../tools/common.mk

all: smoke-tests

smoke-tests:
$(info Smoke testing all libraries...)
$(RULE)testlibs="$(shell find $(LIBS) -type f | xargs)"; for lib in $$testlibs; do \
bash ./testjar.sh "$$lib"; \
echo ""; \
done
Empty file added tests/smoke/README.md
Empty file.
18 changes: 18 additions & 0 deletions tests/smoke/smoketest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

RED="\033[31m";
GRAY="\033[90m";
ENDCOLOR="\033[0m";

success="";
failure="⚠️";

bash -c "$2" 2> /dev/null > /dev/null;
_ret=$?

if [ $_ret -ne 0 ] ; then
echo -e "$failure $1 ${GRAY}${2}${ENDCOLOR}"
exit $_ret
else
echo -e "$success $1 ${GRAY}${2}${ENDCOLOR}";
fi
12 changes: 12 additions & 0 deletions tests/smoke/testjar.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

RED="\033[31m";
GRAY="\033[90m";
ENDCOLOR="\033[0m";

lib="$1";

echo -e "- ${GRAY}Testing${ENDCOLOR} ${lib}";
bash ./smoketest.sh "exists" "file $lib";
bash ./smoketest.sh "valid jar" "jar --validate --file $lib";
bash ./smoketest.sh "valid module" "jar --describe-module --file $lib";

0 comments on commit 7afcd3f

Please sign in to comment.