Skip to content

Commit

Permalink
Kickstart a CLI test suite
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <[email protected]>
  • Loading branch information
jviotti committed Nov 7, 2024
1 parent 95699ee commit e9699bc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ jobs:
- run: docker build --tag registry . --progress plain
- run: docker compose build
- run: docker compose up --detach --wait
- run: make test PRESET=Release
- run: make test-e2e PRESET=Release
- run: docker compose down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM debian:bookworm AS builder
RUN apt-get --yes update && apt-get install --yes --no-install-recommends \
build-essential cmake && apt-get clean && rm -rf /var/lib/apt/lists/*

COPY Makefile /source/Makefile
COPY cmake /source/cmake
COPY src /source/src
COPY schemas /source/schemas
Expand All @@ -19,6 +20,8 @@ RUN cmake --build /build --config Release --parallel 2
RUN cmake --install ./build --prefix /usr --verbose \
--config Release --component sourcemeta_registry

RUN make test PREFIX=/usr

FROM debian:bookworm-slim
RUN apt-get --yes update && apt-get install --yes --no-install-recommends \
ca-certificates && apt-get clean && rm -rf /var/lib/apt/lists/*
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ lint:

.PHONY: test
test:
./test/cli/index/no-options.sh $(PREFIX)/bin/sourcemeta-registry-index

.PHONY: test-e2e
test-e2e:
$(HURL) --test \
--variable base=$(shell jq --raw-output '.url' < $(SANDBOX)/configuration.json) \
test/e2e/*.hurl
Expand Down
20 changes: 20 additions & 0 deletions test/cli/index/no-options.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

set -o errexit
set -o nounset

TMP="$(mktemp -d)"
clean() { rm -rf "$TMP"; }
trap clean EXIT

"$1" > "$TMP/output.txt" && CODE="$?" || CODE="$?"
test "$CODE" = "1" || exit 1

VERSION="$(grep '^project' < CMakeLists.txt | head -n 1 | cut -d ' ' -f 3)"

cat << EOF > "$TMP/expected.txt"
Sourcemeta Registry v$VERSION
Usage: sourcemeta-registry-index <configuration.json> <path/to/output/directory>
EOF

diff "$TMP/output.txt" "$TMP/expected.txt"

0 comments on commit e9699bc

Please sign in to comment.