Skip to content

Commit

Permalink
test: remove C++ Jsonnet tests from ui-tests and test them in a dedic…
Browse files Browse the repository at this point in the history
…ated CI job instead
  • Loading branch information
eduardosm committed Jan 2, 2025
1 parent c8ef00c commit ccb359b
Show file tree
Hide file tree
Showing 27 changed files with 118 additions and 1,787 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,19 @@ jobs:
run: ./ci/install-rust.sh "${{ matrix.rust-version }}" --profile minimal
- run: ./ci/build-and-test.sh

external-tests:
runs-on: ubuntu-24.04
strategy:
matrix:
include:
- rust-version: msrv
- rust-version: stable
steps:
- uses: actions/checkout@v4
- name: Install Rust
run: ./ci/install-rust.sh "${{ matrix.rust-version }}" --profile minimal
- run: ./ci/external-tests.sh

package-crates:
runs-on: ubuntu-24.04
steps:
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,3 @@ Licensed under either of
<https://opensource.org/licenses/MIT>)

at your option.

Part of the test suite ([ui-tests/jsonnet-0.20.0](ui-tests/jsonnet-0.20.0)) is
taken from the [C++ implementation](https://github.com/google/jsonnet), which
is licensed under Apache 2.0.
105 changes: 105 additions & 0 deletions ci/external-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/usr/bin/env bash
set -euo pipefail

. ci/utils.sh

begin_group "Fetch dependencies"
cargo fetch --locked
end_group

begin_group "Build"
cargo build -p rsjsonnet --frozen
end_group

ext_jsonnet_ver="0.20.0"
begin_group "Download jsonnet $ext_jsonnet_ver"
curl -fL "https://github.com/google/jsonnet/archive/refs/tags/v${ext_jsonnet_ver}.tar.gz" | tar -xz
end_group

begin_group "Test"

ext_src_dir="$(readlink -f -- "jsonnet-$ext_jsonnet_ver")"
test_bin="$(readlink -f -- "target/debug/rsjsonnet")"

failures=0

cd "$ext_src_dir/test_suite"
for test in *.jsonnet; do
# Skip error tests
#if [[ "$test" == error.* ]]; then
# continue
#fi

extra_args=()

if [[ "$test" =~ ^tla[.] ]]; then
extra_args+=("--tla-str" "var1=test" "--tla-code" "var2={x:1,y:2}")
else
extra_args+=("--ext-str" "var1=test" "--ext-code" "var2={x:1,y:2}")
fi

echo -n "test $test ..."
set +e
(
NO_COLOR=1 "$test_bin" "${extra_args[@]}" "$test" > test_result.stdout 2> test_result.stderr
exit_code=$?

if [[ "$test" = error.* ]] || [ "$test" = "invariant_manifest.jsonnet" ]; then
if [[ $exit_code -ne 1 ]]; then
echo "Finished with exit code $exit_code"
exit 1
fi
else
if [[ $exit_code -ne 0 ]]; then
echo "Finished with exit code $exit_code"
echo "stderr:"
cat test_result.stderr
exit 1
fi

if [ "$test" = "trace.jsonnet" ]; then
# Skip checking output for trace test
exit 0
fi

if [ -s test_result.stderr ]; then
echo "stderr is not empty:"
cat test_result.stderr
exit 1
fi

if [ "$test" = "unparse.jsonnet" ]; then
# Skip checking stdout for unparse.jsonnet due to rounding differences
exit 0
fi

if [ ! -e "$test.golden" ]; then
echo "true" > "$test.golden"
fi

diff "$test.golden" test_result.stdout > stdout.diff
if [ -s stdout.diff ]; then
echo "unexpected stdout"
cat stdout.diff
exit 1
fi
fi
) > test_report.txt 2>&1
exit_code=$?
set -e

if [[ $exit_code -ne 0 ]]; then
echo " fail"
failures=$((failures + 1))
cat test_report.txt
else
echo " ok"
fi
done

end_group

if [[ $failures -ne 0 ]]; then
echo "Failed $failures test(s)"
exit 1
fi
1 change: 0 additions & 1 deletion ui-tests/README.txt

This file was deleted.

52 changes: 0 additions & 52 deletions ui-tests/jsonnet-0.20.0/arith_bool.jsonnet

This file was deleted.

139 changes: 0 additions & 139 deletions ui-tests/jsonnet-0.20.0/arith_float.jsonnet

This file was deleted.

58 changes: 0 additions & 58 deletions ui-tests/jsonnet-0.20.0/arith_string.jsonnet

This file was deleted.

Loading

0 comments on commit ccb359b

Please sign in to comment.