Skip to content

Commit

Permalink
Selfhost: independent test runner (#477)
Browse files Browse the repository at this point in the history
* Selfhost: independent test runner

This adds a new test runner (in nodejs, for convenience) which uses
the current installation of `abra` to run the lexer, parser,
typechecker, and compiler tests against the assertion files. Once we
start using features in the compiler that are _not_ supported by the
reference implementation (for example, tuple destructuring, which is
already an example of the selfhosted compiler advancing beyond the
initial reference implementation), we will no longer rely on the
original rust-based implementation.

* Tar flags...

* Tar flags...

* github action debugging

* github action debugging 2

* github action debugging 3

* github action debugging 4

* github action debugging 5

* github action debugging 6

* Cleanup, and adding colors to selfhost test runner

* Selfhost: adding tuple destructuring

Now that tuple destructuring is supported by the compiler (selfhosted)
and we're bootstrapping using the initial selfhosted compiler, update
the compiler to use tuple destructuring. Also, add a separate testing
pass to build the next compiler and ensure the tests pass against that
compiler too.

* Removing old rust-based selfhosted test suite

* Updating release gh actions script to not depend on reference rust+llvm compiler
  • Loading branch information
kengorab authored Oct 28, 2024
1 parent b13c326 commit 9180944
Show file tree
Hide file tree
Showing 18 changed files with 1,307 additions and 1,761 deletions.
35 changes: 7 additions & 28 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,12 @@ jobs:
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Cache Cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Cache LLVM
id: cache-llvm
uses: actions/cache@v3
with:
path: ./llvm
key: llvm-11.1.0
- name: Cache QBE
id: cache-qbe
uses: actions/cache@v3
with:
path: ./qbe/qbe-1.2
key: qbe-1.2
- name: Install LLVM (11.1.0)
run: |
mkdir -p llvm
curl -L "https://github.com/llvm/llvm-project/releases/download/llvmorg-11.1.0/clang+llvm-11.1.0-x86_64-linux-gnu-ubuntu-20.10.tar.xz" > llvm.tar.xz
tar x --xz -C llvm --strip-components=1 -f llvm.tar.xz
if: steps.cache-llvm.outputs.cache-hit != 'true'
- name: Setup LLVM
run: |
sudo apt-get update
sudo apt-get install -y libtinfo6
echo "PATH=$(pwd)/llvm/bin:$PATH" >> $GITHUB_ENV
echo "LLVM_CONFIG=$(pwd)/llvm/bin/llvm-config" >> $GITHUB_ENV
- name: Install QBE
run: |
mkdir -p qbe
Expand All @@ -55,10 +29,15 @@ jobs:
- name: Setup QBE
run: |
echo "PATH=$(pwd)/qbe/qbe-1.2:$PATH" >> $GITHUB_ENV
- name: Build reference compiler
run: cargo build
- name: Install ext dependencies
run: ./configure-libgc.sh
- name: Install abra
run: |
mkdir abra-linux
wget https://github.com/kengorab/abra-lang/releases/latest/download/abra-linux.tar.gz
tar -xzf abra-linux.tar.gz -C abra-linux
echo "PATH=$(pwd)/abra-linux:$PATH" >> $GITHUB_ENV
echo "ABRA_HOME=`realpath $(pwd)/abra-linux/std`" >> $GITHUB_ENV
- name: Build package
run: |
cd selfhost
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/selfhost.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Test selfhosted

on:
push:
branches:
- master
pull_request:

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Cache QBE
id: cache-qbe
uses: actions/cache@v3
with:
path: ./qbe/qbe-1.2
key: qbe-1.2
- name: Install QBE
run: |
mkdir -p qbe
cd qbe
wget https://c9x.me/compile/release/qbe-1.2.tar.xz
tar -xf qbe-1.2.tar.xz
cd qbe-1.2
make
if: steps.cache-qbe.outputs.cache-hit != 'true'
- name: Setup QBE
run: |
echo "PATH=$(pwd)/qbe/qbe-1.2:$PATH" >> $GITHUB_ENV
- name: Install ext dependencies
run: ./configure-libgc.sh
- name: Install abra
run: |
mkdir abra-linux
wget https://github.com/kengorab/abra-lang/releases/latest/download/abra-linux.tar.gz
tar -xzf abra-linux.tar.gz -C abra-linux
echo "PATH=$(pwd)/abra-linux:$PATH" >> $GITHUB_ENV
echo "ABRA_HOME=`realpath $(pwd)/abra-linux/std`" >> $GITHUB_ENV
- name: Run tests
run: |
cd selfhost
node test/run-tests.js
- name: Run tests against compiler-next
run: |
cd selfhost
abra build -o compiler_next ./src/compiler.test.abra
COMPILER_BIN=./._abra/compiler_next node test/run-tests.js
16 changes: 0 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ members = [
"abra_lsp",
"abra_native",
"abra_wasm",
"selfhost_test",
]
9 changes: 7 additions & 2 deletions selfhost/gen-pkg/abraw
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,13 @@ mkdir -p "$dotabradir"
touch "$dotabradir/$outfile.ssa"
: > "$dotabradir/$outfile.ssa" # truncate file

export ABRA_HOME="$abra_root/std"
$(echo "$abra_root/compiler $filepath $outfile")
if [[ -z "$ABRA_HOME" ]]; then
echo "Cannot determine ABRA_HOME. Ensure the environment variable exists and points to the std/ dir of the installation"
exit 1
fi

compiler_bin="${COMPILER_BIN:-"$abra_root/compiler"}"
$(echo "$compiler_bin $filepath $outfile")

qbe -o "$dotabradir/$outfile.s" "$dotabradir/$outfile.ssa"

Expand Down
Loading

0 comments on commit 9180944

Please sign in to comment.