Fork of daniellemaywood.uk/gleam — Wasm codegen work
1# SPDX-License-Identifier: Apache-2.0
2# SPDX-FileCopyrightText: 2025 The Gleam contributors
3
4#/usr/bin/env sh
5
6set -eu
7
8should_succeed() {
9 echo
10 echo Running: "$@"
11
12 EXIT_CODE=0
13 cargo run -- $@ > /dev/null 2>&1 || EXIT_CODE=$?
14 if [ $EXIT_CODE -ne 0 ]
15 then
16 echo ERROR: Command should have succeeded
17 exit 1
18 else
19 echo Test Passed '(command run successfully)'
20 fi
21}
22
23should_fail() {
24 echo
25 echo Running: "$@"
26
27 EXIT_CODE=0
28 cargo run -- $@ > /dev/null 2>&1 || EXIT_CODE=$?
29
30 if [ $EXIT_CODE -eq 0 ]
31 then
32 echo ERROR: Command should have failed
33 exit 1
34 else
35 echo Test Passed '(command errored as expected)'
36 fi
37}
38
39all_targets() {
40 $@ --target erlang
41 $@ --target javascript --runtime nodejs
42 $@ --target javascript --runtime deno
43 $@ --target javascript --runtime bun
44}
45
46# Ensure the project builds correctly
47should_succeed build --target erlang
48should_succeed build --target javascript
49
50all_targets should_succeed run --module passing
51
52# Since a single failing `assert` will exit immediately, we must test each
53# failing case individually as separate modules.
54all_targets should_fail run --module failing1
55all_targets should_fail run --module failing2
56all_targets should_fail run --module failing3
57all_targets should_fail run --module failing4