Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

1# SPDX-License-Identifier: Apache-2.0 2# SPDX-FileCopyrightText: 2026 The Gleam contributors 3 4#!/bin/sh 5 6set -eu 7 8GLEAM_COMMAND=${GLEAM_COMMAND:-"cargo run --quiet --"} 9 10g() { 11 echo "Running: $GLEAM_COMMAND $@" 12 $GLEAM_COMMAND "$@" 13} 14 15# Create a monorepo with two sibling packages in a temp directory 16REPO_DIR=$(mktemp -d) 17trap 'rm -rf "$REPO_DIR"' EXIT 18 19mkdir -p "$REPO_DIR/package_a/src" "$REPO_DIR/package_b/src" 20 21cat > "$REPO_DIR/package_b/gleam.toml" << 'TOML' 22name = "package_b" 23version = "0.1.0" 24 25[dependencies] 26TOML 27 28cat > "$REPO_DIR/package_b/src/package_b.gleam" << 'GLEAM' 29pub fn greeting() -> String { 30 "hello from package_b" 31} 32GLEAM 33 34cat > "$REPO_DIR/package_a/gleam.toml" << 'TOML' 35name = "package_a" 36version = "0.1.0" 37 38[dependencies] 39package_b = { path = "../package_b" } 40TOML 41 42cat > "$REPO_DIR/package_a/src/package_a.gleam" << 'GLEAM' 43import package_b 44 45pub fn hello() -> String { 46 package_b.greeting() 47} 48GLEAM 49 50cd "$REPO_DIR" 51git init -q 52git add . 53git -c user.name="Test" -c user.email="test@example.com" commit -q -m "Initial commit" 54git branch -M main 55REF=$(git rev-parse HEAD) 56cd "$OLDPWD" 57 58echo Resetting the build directory to get to a known state 59rm -fr build 60 61cat > gleam.toml << EOF 62name = "git_deps_path" 63version = "0.1.0" 64 65[dependencies] 66package_a = { git = "file://${REPO_DIR}", ref = "${REF}", path = "package_a" } 67EOF 68 69g update 70g check 71 72echo 73echo Testing with a branch ref, two packages from one repo, and a clean rebuild 74rm -fr build 75 76cat > gleam.toml << EOF 77name = "git_deps_path" 78version = "0.1.0" 79 80[dependencies] 81package_a = { git = "file://${REPO_DIR}", ref = "main", path = "package_a" } 82package_b = { git = "file://${REPO_DIR}", ref = "main", path = "package_b" } 83EOF 84 85g update 86 87echo Checking that the hard-linked packages do not contain a .git entry 88if [ -e "build/packages/package_a/.git" ]; then 89 echo "build/packages/package_a/.git should not exist" 90 exit 1 91fi 92if [ -e "build/packages/package_b/.git" ]; then 93 echo "build/packages/package_b/.git should not exist" 94 exit 1 95fi 96 97EXPECTED_PACKAGE_B=" { name = \"package_b\", version = \"0.1.0\", build_tools = [\"gleam\"], requirements = [], source = \"git\", repo = \"file://${REPO_DIR}\", commit = \"${REF}\", path = \"package_b\" }," 98if ! grep -qFx "$EXPECTED_PACKAGE_B" manifest.toml; then 99 echo "manifest.toml does not lock package_b as a git source. Expected:" 100 echo "$EXPECTED_PACKAGE_B" 101 echo "Got:" 102 cat manifest.toml 103 exit 1 104fi 105 106rm -fr build 107g check 108 109echo 110echo Testing that a new commit on a branch refreshes a transitive path dependency 111rm -fr build 112 113cat > gleam.toml << EOF 114name = "git_deps_path" 115version = "0.1.0" 116 117[dependencies] 118package_a = { git = "file://${REPO_DIR}", ref = "main", path = "package_a" } 119EOF 120 121g update 122 123echo Checking that the transitive package_b starts at the original commit 124if ! grep -qF "hello from package_b" build/packages/package_b/src/package_b.gleam; then 125 echo "build/packages/package_b should contain the original greeting" 126 cat build/packages/package_b/src/package_b.gleam 127 exit 1 128fi 129 130echo Making a new commit that changes package_b without changing its version 131cat > "$REPO_DIR/package_b/src/package_b.gleam" << 'GLEAM' 132pub fn greeting() -> String { 133 "hello from package_b v2" 134} 135GLEAM 136git -C "$REPO_DIR" add . 137git -C "$REPO_DIR" -c user.name="Test" -c user.email="test@example.com" commit -q -m "Update package_b" 138NEW_REF=$(git -C "$REPO_DIR" rev-parse HEAD) 139 140g update 141 142echo Checking that build/packages/package_b was refreshed to the new commit 143if ! grep -qF "hello from package_b v2" build/packages/package_b/src/package_b.gleam; then 144 echo "build/packages/package_b was not refreshed to the new commit" 145 cat build/packages/package_b/src/package_b.gleam 146 exit 1 147fi 148 149EXPECTED_PACKAGE_B=" { name = \"package_b\", version = \"0.1.0\", build_tools = [\"gleam\"], requirements = [], source = \"git\", repo = \"file://${REPO_DIR}\", commit = \"${NEW_REF}\", path = \"package_b\" }," 150if ! grep -qFx "$EXPECTED_PACKAGE_B" manifest.toml; then 151 echo "manifest.toml does not lock package_b at the new commit. Expected:" 152 echo "$EXPECTED_PACKAGE_B" 153 echo "Got:" 154 cat manifest.toml 155 exit 1 156fi 157 158echo 159echo Testing that an unresolvable ref fails 160rm -fr build 161 162cat > gleam.toml << EOF 163name = "git_deps_path" 164version = "0.1.0" 165 166[dependencies] 167package_a = { git = "file://${REPO_DIR}", ref = "no-such-ref", path = "package_a" } 168EOF 169 170if g update; then 171 echo "g update should have failed for an unresolvable ref" 172 exit 1 173fi 174 175echo 176echo Success! 💖 177echo