Skip to content

Commit

Permalink
Fix lockfile smoke tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcadman committed Nov 20, 2023
1 parent a2f8eaa commit d115a54
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 83 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ jobs:
run: |
sed --version
- name: Install coreutils
run: |
brew install coreutils
- name: Test sha256sum (used by smoke)
run: |
sha256sum --version
- name: Download and extract wasi-sysroot
run: >
curl
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,12 @@ fast-test-skip-slow:
@${STACK} test --fast ${STACKFLAGS} ${STACKTESTFLAGS} --ta '-p "! /slow tests/"'

SMOKE := $(shell command -v smoke 2> /dev/null)
SHA256SUM := $(shell command -v sha256sum 2> /dev/null)

.PHONY : smoke-only
smoke-only:
@$(if $(SMOKE),, $(error "Smoke not found, please install it from https://github.com/jonaprieto/smoke"))
@$(if $(SHA256SUM),, $(error "sha256sum not found, please install the GNU coreutils package (e.g {apt, brew} install coreutils)"))
@smoke $(shell find tests -name '*.smoke.yaml')

.PHONY : smoke
Expand Down
93 changes: 10 additions & 83 deletions tests/smoke/Commands/compile-dependencies.smoke.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,11 @@ tests:
version: 0.1.0
EOF
checksum=$(sha256sum juvix.yaml | cut -d " " -f 1)
cat <<-EOF > juvix.lock.yaml
version: 2
checksum: $checksum
dependencies:
- path: .juvix-build/stdlib/
dependencies: []
Expand Down Expand Up @@ -323,6 +327,7 @@ tests:
cat <<-EOF > HelloDep.juvix
module HelloDep;
import HelloDep2 open;
import Stdlib.Prelude open;
main : IO := printStringLn "This is from the second commit" >> printStringLn hello;
EOF
Expand All @@ -342,8 +347,9 @@ tests:
git add -A
git commit -m "commit2"
# rebuild the project (should use the first commit
# rebuild the project (should use the first commit)
cd $temp/base
cat juvix.lock.yaml
# compile with the new hash
juvix compile HelloWorld.juvix
Expand All @@ -358,8 +364,7 @@ tests:
- bash
script: |
temp=$(mktemp -d)
echo $temp
# trap 'rm -rf -- "$temp"' EXIT
trap 'rm -rf -- "$temp"' EXIT
# create dependency
mkdir $temp/dep
Expand Down Expand Up @@ -390,7 +395,7 @@ tests:
- git:
url: $temp/dep
name: dep1
ref: $dep1hash
ref: main
version: 0.1.0
EOF
Expand Down Expand Up @@ -423,18 +428,7 @@ tests:
# compile project with new ref - should use lockfile ref
cd $temp/base
cat <<-EOF > juvix.yaml
name: HelloWorld
main: HelloWorld.juvix
dependencies:
- .juvix-build/stdlib
- git:
url: $temp/dep
name: dep1
ref: $dep1hash
version: 0.1.0
EOF
juvix clean
juvix compile HelloWorld.juvix
./HelloWorld
stdout:
Expand Down Expand Up @@ -643,73 +637,6 @@ tests:
contains: "Hello from dep1\nHello from dep2"
exit-status: 0

- name: git-dependencies-lockfile-missing-dependency
command:
shell:
- bash
script: |
temp=$(mktemp -d)
trap 'rm -rf -- "$temp"' EXIT
# create dependency
mkdir $temp/dep1
cd $temp/dep1
git init
cat <<-EOF > HelloDep.juvix
module HelloDep;
import Stdlib.Prelude open;
main : IO := printStringLn "Hello from dep";
EOF
touch juvix.yaml
git add -A
git commit -m "commit1"
dep1hash=$(git rev-parse HEAD)
# create project that uses dependency
mkdir $temp/base
cd $temp/base
cat <<-EOF > juvix.yaml
name: HelloWorld
main: HelloWorld.juvix
dependencies:
- .juvix-build/stdlib/
- git:
url: $temp/dep1
name: dep1
ref: $dep1hash
version: 0.1.0
EOF
cat <<-EOF > juvix.lock.yaml
dependencies:
- path: .juvix-build/stdlib/
dependencies: []
EOF
cat <<-EOF > HelloWorld.juvix
-- HelloWorld.juvix
module HelloWorld;
import Stdlib.Prelude open;
import HelloDep;
main : IO := HelloDep.main;
EOF
# compile and run the project
juvix compile HelloWorld.juvix
stderr:
contains: "dep1"
stdout:
matches:
regex: ".*"
exit-status: 1

- name: git-dependencies-update-ref-offline
command:
shell:
Expand Down

0 comments on commit d115a54

Please sign in to comment.