Skip to content

Commit c0a32ae

Browse files
committed
more tests, misc improvements
1 parent 4637d63 commit c0a32ae

File tree

4 files changed

+59
-11
lines changed

4 files changed

+59
-11
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ members = [
3131
]
3232

3333
[workspace.package]
34+
3435
authors = ["The Roc Contributors"]
3536
edition = "2021"
3637
license = "UPL-1.0"
@@ -39,8 +40,8 @@ repository = "https://github.com/roc-lang/basic-cli"
3940

4041
[workspace.dependencies]
4142
# Core Roc types
42-
# roc-nightly: 2026-03-03
43-
roc_std_new = { git = "https://github.com/roc-lang/roc", rev = "3fa8df31997e3e233d5bda63eec8737ccd3ce941" }
43+
# roc-nightly: 2026-03-06
44+
roc_std_new = { git = "https://github.com/roc-lang/roc", rev = "a02d2287afd24d9f13baff3a5c6059e795b01661" }
4445

4546
# Internal crates
4647
roc_io_error = { path = "crates/roc_io_error" }

ci/all_tests.sh

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ cleanup() {
2727
for example in "${MIGRATED_EXAMPLES[@]}"; do
2828
rm -f "examples/${example}"
2929
done
30+
# Remove built test binaries
31+
for f in tests/*.roc; do
32+
if [ -f "$f" ]; then
33+
rm -f "tests/$(basename "${f%.roc}")"
34+
fi
35+
done
3036

3137
# Remove bundle file
3238
if [ -n "${BUNDLE_FILE:-}" ] && [ -f "$BUNDLE_FILE" ]; then
@@ -45,7 +51,9 @@ echo "=== basic-cli CI ==="
4551
echo ""
4652

4753
# Check if cached roc exists and matches pinned version
48-
ROC_DIR="roc_nightly-${ROC_NIGHTLY_DATE}-${ROC_NIGHTLY_COMMIT}"
54+
# Derive directory name from archive name (strip .tar.gz or .zip extension)
55+
ROC_DIR="${ROC_NIGHTLY_ARCHIVE%.tar.gz}"
56+
ROC_DIR="${ROC_DIR%.zip}"
4957
if [ -d "$ROC_DIR" ] && [ -f "$ROC_DIR/roc" ]; then
5058
CACHED_VERSION=$("./$ROC_DIR/roc" version 2>/dev/null || echo "unknown")
5159
if echo "$CACHED_VERSION" | grep -q "$ROC_NIGHTLY_COMMIT"; then
@@ -71,9 +79,6 @@ if [ "$NEED_DOWNLOAD" = true ]; then
7179
tar -xzf "$ROC_NIGHTLY_ARCHIVE"
7280
rm -f "$ROC_NIGHTLY_ARCHIVE"
7381

74-
# Find the extracted directory
75-
ROC_DIR=$(ls -d roc_nightly-*/ 2>/dev/null | head -1 | sed 's|/$||')
76-
7782
# Add to GITHUB_PATH if running in CI
7883
if [ -n "${GITHUB_PATH:-}" ]; then
7984
echo "$(pwd)/$ROC_DIR" >> "$GITHUB_PATH"
@@ -120,6 +125,9 @@ MIGRATED_EXAMPLES=(
120125
EXAMPLES_DIR="${ROOT_DIR}/examples/"
121126
export EXAMPLES_DIR
122127

128+
TESTS_DIR="${ROOT_DIR}/tests/"
129+
export TESTS_DIR
130+
123131
# Check if all target libraries exist for bundling
124132
ALL_TARGETS_EXIST=true
125133
for target in x64mac arm64mac x64musl arm64musl; do
@@ -177,6 +185,12 @@ else
177185
echo "Run './build.sh --all' first to test with bundled platform"
178186
fi
179187

188+
# Collect test files from TESTS_DIR
189+
TESTS_FILES=()
190+
for roc_file in "${TESTS_DIR}"*.roc; do
191+
[ -f "$roc_file" ] && TESTS_FILES+=("$(basename "${roc_file%.roc}")")
192+
done
193+
180194
# roc check migrated examples
181195
echo ""
182196
echo "=== Checking examples ==="
@@ -185,6 +199,14 @@ for example in "${MIGRATED_EXAMPLES[@]}"; do
185199
roc check --no-cache "examples/${example}.roc"
186200
done
187201

202+
# roc check tests
203+
echo ""
204+
echo "=== Checking tests ==="
205+
for test in "${TESTS_FILES[@]}"; do
206+
echo "Checking: ${test}.roc"
207+
roc check --no-cache "tests/${test}.roc"
208+
done
209+
188210
# roc build migrated examples
189211
echo ""
190212
if [ "$USE_BUNDLE" = true ]; then
@@ -198,6 +220,15 @@ for example in "${MIGRATED_EXAMPLES[@]}"; do
198220
mv "./${example}" "examples/"
199221
done
200222

223+
# roc build tests
224+
echo ""
225+
echo "=== Building tests ==="
226+
for test in "${TESTS_FILES[@]}"; do
227+
echo "Building: ${test}.roc"
228+
roc build --no-cache "tests/${test}.roc"
229+
mv "./${test}" "tests/"
230+
done
231+
201232
# Run expect tests
202233
echo ""
203234
echo "=== Running expect tests ==="
@@ -217,6 +248,22 @@ for example in "${MIGRATED_EXAMPLES[@]}"; do
217248
fi
218249
done
219250

251+
# Run test expect tests
252+
for test in "${TESTS_FILES[@]}"; do
253+
echo ""
254+
echo "--- Testing: $test ---"
255+
set +e
256+
expect "ci/expect_scripts/${test}.exp"
257+
EXIT_CODE=$?
258+
set -e
259+
if [ $EXIT_CODE -eq 0 ]; then
260+
echo "PASS: $test"
261+
else
262+
echo "FAIL: $test (exit code: $EXIT_CODE)"
263+
FAILED=1
264+
fi
265+
done
266+
220267
echo ""
221268
if [ $FAILED -eq 0 ]; then
222269
if [ "$USE_BUNDLE" = true ]; then

tests/cmd-test.roc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ main! = |_args| {
4141
)?
4242

4343
# Test StdoutContainsInvalidUtf8 - blocked by compiler bug
44-
# expect_err(
45-
# Cmd.new("printf").args(["\\377\\376"]).exec_output!(),
46-
# "Try.Err(StdoutContainsInvalidUtf8({ cmd_str: \"{ cmd: printf, args: \\377\\376 }\", err: BadUtf8({ index: 0, problem: InvalidStartByte }) }))"
47-
# )?
44+
expect_err(
45+
Cmd.new("printf").args(["\\377\\376"]).exec_output!(),
46+
"Try.Err(StdoutContainsInvalidUtf8({ cmd_str: \"{ cmd: printf, args: \\\\377\\\\376 }\", err: BadUtf8({ index: 0, problem: InvalidStartByte }) }))"
47+
)?
4848

4949
# exec_output_bytes!
5050
expect_err(

0 commit comments

Comments
 (0)