mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-11 02:25:39 +03:00
try retrieving runtime tests from Share
This commit is contained in:
parent
80fc452dd8
commit
cac59a7edb
55
.github/workflows/ci.yaml
vendored
55
.github/workflows/ci.yaml
vendored
@ -25,7 +25,8 @@ env:
|
||||
jit_src_scheme: "unison-jit-src/scheme-libs/racket"
|
||||
jit_dist: "unison-jit-dist"
|
||||
jit_generator_os: ubuntu-20.04
|
||||
base-codebase: "~/.cache/unisonlanguage/base.unison"
|
||||
runtime_tests_version: "@unison/runtime-tests/main"
|
||||
runtime_tests_codebase: "~/.cache/unisonlanguage/runtime-tests.unison"
|
||||
|
||||
# refers to all tests that depend on **/unison-src/**
|
||||
unison_src_test_results: "unison-src-test-results"
|
||||
@ -212,17 +213,19 @@ jobs:
|
||||
if: runner.os == 'macOS' && steps.cache-ucm-binaries.outputs.cache-hit != 'true'
|
||||
run: echo | stack ghci
|
||||
|
||||
- name: cache base codebase
|
||||
id: cache-base-codebase
|
||||
- name: set up test codebase cache vars
|
||||
if: steps.cache-ucm-binaries.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
echo "runtime_tests_causalhash=$(scripts/get-share-hash.sh ${{env.runtime_tests_version}})" >> $GITHUB_ENV
|
||||
|
||||
- name: cache testing codebase
|
||||
id: cache-testing-codebase
|
||||
if: steps.cache-ucm-binaries.outputs.cache-hit != 'true'
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ env.base-codebase }}
|
||||
# key = base transcript contents + sqlite schema version
|
||||
key: base.unison-${{hashFiles('**/unison-src/builtin-tests/base.md', '**/codebase2/codebase-sqlite/U/Codebase/Sqlite/Queries.hs')}}.
|
||||
|
||||
- name: create base.md codebase
|
||||
if: steps.cache-base-codebase.outputs.cache-hit != 'true'
|
||||
run: ${{env.ucm}} transcript.fork -C ${{env.base-codebase}} -S ${{env.base-codebase}} unison-src/builtin-tests/base.md
|
||||
path: ${{ env.runtime_tests_codebase }}
|
||||
key: runtime-tests-codebase-${{env.runtime_tests_causalhash}}
|
||||
restore-keys: runtime-tests-codebase-
|
||||
|
||||
- name: interpreter tests
|
||||
# this one should be re-run if the ucm binaries have changed or unison-src/ has changed
|
||||
@ -231,7 +234,10 @@ jobs:
|
||||
&& (steps.cache-ucm-binaries.outputs.cache-hit != 'true'
|
||||
|| steps.cache-unison-src-test-results.outputs.cache-hit != 'true')
|
||||
run: |
|
||||
${{ env.ucm }} transcript.fork -c ${{env.base-codebase}} unison-src/builtin-tests/interpreter-tests.md
|
||||
envsubst '$runtime_test_version' \
|
||||
< unison-src/builtin-tests/interpreter-tests.tpl.md \
|
||||
> unison-src/builtin-tests/interpreter-tests.md
|
||||
${{ env.ucm }} transcript.fork -c ${{ env.runtime_tests_codebase }} unison-src/builtin-tests/interpreter-tests.md
|
||||
cat unison-src/builtin-tests/interpreter-tests.output.md
|
||||
git diff --exit-code unison-src/builtin-tests/interpreter-tests.output.md
|
||||
|
||||
@ -342,7 +348,6 @@ jobs:
|
||||
path: ${{ env.jit_src_scheme }}/**
|
||||
if-no-files-found: error
|
||||
|
||||
|
||||
build-jit-binary:
|
||||
if: always() && needs.generate-jit-source.result == 'success'
|
||||
name: Build JIT binary ${{ matrix.os }}
|
||||
@ -400,9 +405,9 @@ jobs:
|
||||
- uses: Bogdanp/setup-racket@v1.11
|
||||
if: steps.restore-jit-binaries.outputs.cache-hit != 'true'
|
||||
with:
|
||||
architecture: 'x64'
|
||||
distribution: 'full'
|
||||
variant: 'CS'
|
||||
architecture: x64
|
||||
distribution: full
|
||||
variant: CS
|
||||
version: ${{env.racket_version}}
|
||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||
if: runner.os == 'Linux' && steps.restore-jit-binaries.outputs.cache-hit != 'true'
|
||||
@ -446,17 +451,27 @@ jobs:
|
||||
if: steps.restore-jit-binaries.outputs.cache-hit != 'true'
|
||||
run: chmod +x ${{ env.ucm }}
|
||||
|
||||
- name: get base codebase
|
||||
- name: set up test codebase cache vars
|
||||
if: steps.restore-jit-binaries.outputs.cache-hit != 'true'
|
||||
uses: actions/cache/restore@v4
|
||||
run: |
|
||||
echo "runtime_tests_causalhash=$(scripts/get-share-hash.sh ${{env.runtime_tests_version}})" >> $GITHUB_ENV
|
||||
|
||||
- name: cache testing codebase
|
||||
id: cache-testing-codebase
|
||||
if: steps.restore-jit-binaries.outputs.cache-hit != 'true'
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ env.base-codebase}}
|
||||
key: base.unison-${{hashFiles('**/unison-src/builtin-tests/base.md', '**/codebase2/codebase-sqlite/U/Codebase/Sqlite/Queries.hs')}}.
|
||||
path: ${{ env.runtime_tests_codebase }}
|
||||
key: runtime-tests-codebase-${{env.runtime_tests_causalhash}}
|
||||
restore-keys: runtime-tests-codebase-
|
||||
|
||||
- name: jit integration test ${{ matrix.os }}
|
||||
if: runner.os != 'Windows' && steps.restore-jit-binaries.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
${{ env.ucm }} transcript.fork --runtime-path ${{ env.jit_dist_exe }} -c ${{env.base-codebase}} unison-src/builtin-tests/jit-tests.md
|
||||
envsubst '$runtime_test_version' \
|
||||
< unison-src/builtin-tests/jit-tests.tpl.md \
|
||||
> unison-src/builtin-tests/jit-tests.md
|
||||
${{ env.ucm }} transcript.fork --runtime-path ${{ env.jit_dist_exe }} -c ${{env.runtime_tests_codebase}} unison-src/builtin-tests/jit-tests.md
|
||||
cat unison-src/builtin-tests/jit-tests.output.md
|
||||
git diff --exit-code unison-src/builtin-tests/jit-tests.output.md
|
||||
|
||||
|
53
scripts/get-share-hash.sh
Executable file
53
scripts/get-share-hash.sh
Executable file
@ -0,0 +1,53 @@
|
||||
#!/bin/bash
|
||||
|
||||
getHash() {
|
||||
input=$1
|
||||
|
||||
# Remove the initial '@' and split the string by '/'
|
||||
IFS='/' read -r -a parts <<< "${input:1}"
|
||||
|
||||
user="${parts[0]}"
|
||||
project="${parts[1]}"
|
||||
type="" # Can be either 'branch' or 'release'
|
||||
name="" # Will hold either branch name or release version
|
||||
|
||||
# Check if it's a release or a branch
|
||||
if [[ "${parts[2]}" == "releases" ]]; then
|
||||
type="release"
|
||||
name="${parts[3]}"
|
||||
else
|
||||
type="branch"
|
||||
# Reconstruct branch name from the remaining parts
|
||||
for (( i = 2; i < ${#parts[@]}; i++ )); do
|
||||
if [[ -z "$name" ]]; then
|
||||
name="${parts[i]}"
|
||||
else
|
||||
name="$name/${parts[i]}"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
# echo "user: $user, project: $project, type: $type, name: $name"
|
||||
|
||||
if [[ "$type" == "branch" ]]; then
|
||||
url=https://api.unison-lang.org/users/${user}/projects/${project}/branches/${name}
|
||||
hash=$(curl -s $url | jq -r '.causalHash')
|
||||
else
|
||||
url=https://api.unison-lang.org/users/${user}/projects/${project}/releases/${name}
|
||||
hash=$(curl -s $url | jq -r '.causalHashUnsquashed')
|
||||
fi
|
||||
# echo "url: $url, hash: $hash"
|
||||
echo "$hash"
|
||||
}
|
||||
|
||||
# print usage if there are no arguments
|
||||
if [ $# -eq 0 ]; then
|
||||
# print to the EOF
|
||||
cat <<EOF
|
||||
Example usage:
|
||||
$0 @user/project/branchname
|
||||
$0 @user/project/releases/1.0.0
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
getHash "$1"
|
@ -1,105 +0,0 @@
|
||||
|
||||
Note: This should be forked off of the codebase created by base.md
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/testlib.u
|
||||
.> add
|
||||
```
|
||||
|
||||
If you want to define more complex tests somewhere other than `tests.u`, just `load my-tests.u` then `add`,
|
||||
then reference those tests (which should be of type `'{IO,Exception,Tests} ()`, written using calls
|
||||
to `Tests.check` and `Tests.checkEqual`).
|
||||
|
||||
```ucm:hide
|
||||
.> alias.type #ggh649864d ThreadKilledFailure
|
||||
.> load unison-src/builtin-tests/concurrency-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/array-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/link-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/math-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/serial-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/tcp-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/tls-chain-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/tls-tests.u
|
||||
.> add
|
||||
.> load unison-src/builtin-tests/bytes-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/list-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> alias.term ##Pattern.captureAs Pattern.captureAs
|
||||
.> load unison-src/builtin-tests/text-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/bytes-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> alias.term ##IO.randomBytes IO.randomBytes
|
||||
.> load unison-src/builtin-tests/io-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/code-lookup.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> alias.term ##Value.validateSandboxed Value.validateSandboxed
|
||||
.> load unison-src/builtin-tests/sandbox-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/tests-interpreter-only.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm
|
||||
.> run tests
|
||||
```
|
||||
|
||||
```ucm
|
||||
.> run tests.interpreter.only
|
||||
```
|
10
unison-src/builtin-tests/interpreter-tests.tpl.md
Normal file
10
unison-src/builtin-tests/interpreter-tests.tpl.md
Normal file
@ -0,0 +1,10 @@
|
||||
```ucm:hide:error
|
||||
.> delete.project nothing
|
||||
.> delete.project runtime-tests
|
||||
.> clone ${runtime_tests_version} runtime-tests/selected
|
||||
```
|
||||
|
||||
```ucm
|
||||
runtime-tests/selected> run tests
|
||||
runtime-tests/selected> run tests.interpreter.only
|
||||
```
|
@ -1,119 +0,0 @@
|
||||
|
||||
Note: This should be forked off of the codebase created by base.md
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/testlib.u
|
||||
.> add
|
||||
```
|
||||
|
||||
If you want to define more complex tests somewhere other than `tests.u`, just `load my-tests.u` then `add`,
|
||||
then reference those tests (which should be of type `'{IO,Exception,Tests} ()`, written using calls
|
||||
to `Tests.check` and `Tests.checkEqual`).
|
||||
|
||||
```ucm:hide
|
||||
.> alias.type #ggh649864d ThreadKilledFailure
|
||||
.> load unison-src/builtin-tests/concurrency-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/array-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/link-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/math-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/serial-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/tcp-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/tls-chain-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/tls-tests.u
|
||||
.> add
|
||||
.> load unison-src/builtin-tests/bytes-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/list-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> alias.term ##Pattern.captureAs Pattern.captureAs
|
||||
.> load unison-src/builtin-tests/text-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/bytes-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> alias.term ##IO.randomBytes IO.randomBytes
|
||||
.> load unison-src/builtin-tests/io-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/code-lookup.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> alias.term ##Value.validateSandboxed Value.validateSandboxed
|
||||
.> load unison-src/builtin-tests/sandbox-tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/tests.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm:hide
|
||||
.> load unison-src/builtin-tests/tests-jit-only.u
|
||||
.> add
|
||||
```
|
||||
|
||||
```ucm
|
||||
.> run.native tests
|
||||
```
|
||||
|
||||
```ucm
|
||||
.> run.native tests.jit.only
|
||||
```
|
||||
|
||||
```unison
|
||||
foo = do
|
||||
go : Nat ->{Exception} ()
|
||||
go = cases
|
||||
0 -> ()
|
||||
n -> go (decrement n)
|
||||
go 1000
|
||||
```
|
||||
|
||||
```ucm
|
||||
.> run.native foo
|
||||
.> run.native foo
|
||||
```
|
27
unison-src/builtin-tests/jit-tests.tpl.md
Normal file
27
unison-src/builtin-tests/jit-tests.tpl.md
Normal file
@ -0,0 +1,27 @@
|
||||
```ucm:hide
|
||||
.> delete.project nothing
|
||||
.> delete.project runtime-tests
|
||||
.> clone ${runtime_tests_version} runtime-tests/selected
|
||||
```
|
||||
|
||||
```ucm
|
||||
runtime-tests/selected> run tests
|
||||
runtime-tests/selected> run tests.jit.only
|
||||
```
|
||||
|
||||
Per Dan:
|
||||
It's testing a flaw in how we were sending code from a scratch file to the native runtime, when that happened multiple times.
|
||||
Related to the verifiable refs and recursive functions.
|
||||
```unison
|
||||
foo = do
|
||||
go : Nat ->{Exception} ()
|
||||
go = cases
|
||||
0 -> ()
|
||||
n -> go (decrement n)
|
||||
go 1000
|
||||
```
|
||||
|
||||
```ucm
|
||||
.> run.native foo
|
||||
.> run.native foo
|
||||
```
|
@ -1,11 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -ex
|
||||
|
||||
ucm=$(stack exec -- which unison)
|
||||
|
||||
base_codebase=${XDG_CACHE_HOME:-"$HOME/.cache"}/unisonlanguage/base.unison
|
||||
|
||||
if [ ! -d $base_codebase ]; then
|
||||
# -S specificies the output codebase (-C specifies the input codebase)
|
||||
$ucm transcript -S $base_codebase unison-src/builtin-tests/base.md
|
||||
fi
|
Loading…
Reference in New Issue
Block a user