Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/cmake-test-release-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,41 @@ jobs:
LLVM_SYMBOLIZER_PATH: ${{github.workspace}}/3rdParty/llvm/release/bin
TSLANG_TEST_PROGRAMS: ${{ matrix.programs }}
KIND: ${{ matrix.kind }}

# wasm32 and wasm64, as in the Windows workflow: the exe legs only, each with its kind of program,
# against the wasm default library built here by this compiler.
- name: Set up Node (wasm tests)
if: matrix.kind == 'exe'
uses: actions/setup-node@v4
with:
node-version: 24

- name: Build wasm Default Library (${{ matrix.programs }})
if: matrix.kind == 'exe'
working-directory: ${{github.workspace}}
shell: bash
env:
TOOL_PATH: ${{github.workspace}}/__build/tslang/ninja/release/bin
LLVM_AR: ${{github.workspace}}/3rdParty/llvm/release/bin/llvm-ar
MODE: ${{ matrix.programs }}
run: |
set -e
git clone --depth 1 https://github.com/ASDAlexander77/TypeScriptCompilerDefaultLib.git
bash ./TypeScriptCompilerDefaultLib/scripts/build_wasm.sh "wasm32 wasm64" "$MODE"

- name: Test wasm32 and wasm64 (${{ matrix.programs }} programs)
if: matrix.kind == 'exe'
working-directory: ${{github.workspace}}/tslang/test/wasm
shell: bash
env:
MODE: ${{ matrix.programs }}
run: |
# wasm-ld, which tslang links a wasm program with
export PATH="${{github.workspace}}/3rdParty/llvm/release/bin:$PATH"
debug=""; if [ "$MODE" = debug ]; then debug=--debug; fi
code=0
node run_tests.mjs --tslang=${{github.workspace}}/__build/tslang/ninja/release/bin/tslang \
--default-lib-repo=${{github.workspace}}/TypeScriptCompilerDefaultLib --require-run -j4 $debug || code=$?
if [ $code -ne 0 ]; then cat out/results.txt; fi
exit $code

44 changes: 44 additions & 0 deletions .github/workflows/cmake-test-release-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,47 @@ jobs:
$filter = if ($env:KIND -eq 'jit') { '-R' } else { '-E' }
ctest -j8 -C ${{ env.BUILD_TYPE }} $filter '^test-jit' -T test --output-on-failure
shell: pwsh

# wasm32 and wasm64 (tslang/test/wasm): the tester's tests and the default library's, under
# -mm=none, rc and own, each program run under Node with the JavaScript host. The exe legs only,
# each with its kind of program (release: --opt; debug: --di --opt_level=0), against the wasm
# default library built here by this compiler from TypeScriptCompilerDefaultLib's main.
# wasm64 needs Node 24 (64-bit tables); --require-run fails a test that is only compiled.
- name: Set up Node (wasm tests)
if: matrix.kind == 'exe'
uses: actions/setup-node@v4
with:
node-version: 24

- name: Build wasm Default Library (${{ matrix.programs }})
if: matrix.kind == 'exe'
working-directory: ${{github.workspace}}
env:
TOOL_PATH: ${{github.workspace}}/__build/tslang/msbuild/x64/release/bin
LLVM_AR: ${{github.workspace}}/3rdParty/llvm/x64/release/bin/llvm-ar.exe
MODE: ${{ matrix.programs }}
run: |
git clone --depth 1 https://github.com/ASDAlexander77/TypeScriptCompilerDefaultLib.git
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
foreach ($arch in 'wasm32', 'wasm64') {
& .\TypeScriptCompilerDefaultLib\scripts\build_wasm.bat $arch $env:MODE
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
}
shell: pwsh

- name: Test wasm32 and wasm64 (${{ matrix.programs }} programs)
if: matrix.kind == 'exe'
working-directory: ${{github.workspace}}/tslang/test/wasm
env:
MODE: ${{ matrix.programs }}
run: |
# wasm-ld, which tslang links a wasm program with
$env:PATH = "${{github.workspace}}\3rdParty\llvm\x64\release\bin;$env:PATH"
$runArgs = @("--tslang=${{github.workspace}}\__build\tslang\msbuild\x64\release\bin\tslang.exe",
"--default-lib-repo=${{github.workspace}}\TypeScriptCompilerDefaultLib", "--require-run", "-j4")
if ($env:MODE -eq 'debug') { $runArgs += '--debug' }
node run_tests.mjs @runArgs
$code = $LASTEXITCODE
if ($code -ne 0) { Get-Content out\results.txt }
exit $code
shell: pwsh
148 changes: 147 additions & 1 deletion .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,20 @@ jobs:
# The Default Library's own tests run in test_defaultlib_windows, one job per memory model,
# against the package this job uploads.

# wasm32 and wasm64 (release and debug, -mm=rc, none and own) into the same tree, so the
# package carries them: defaultlib/lib/<wasm32|wasm64>/unknown/unknown/unknown/<mode>/<mm>.
# They are tested in test_wasm_windows, against the package.
- name: Build wasm Default Library
continue-on-error: false
working-directory: ${{github.workspace}}/TypeScriptCompilerDefaultLib
env:
TOOL_PATH: ${{github.workspace}}/__build/tslang/msbuild/x64/release/bin
LLVM_AR: ${{github.workspace}}/3rdParty/llvm/x64/release/bin/llvm-ar.exe
run: |
.\scripts\build_wasm.bat
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
shell: pwsh

# Android (API 29, arm64-v8a, armeabi-v7a and x86_64): the collector, the async runtime and the default
# library, cross-built with the runner's Android NDK by the same scripts a developer runs.
# tslang links for Android through the NDK too (--android-ndk-path / ANDROID_NDK_HOME).
Expand Down Expand Up @@ -455,6 +469,17 @@ jobs:

# As on Windows: the Default Library's own tests run in test_defaultlib_linux.

# As on Windows: wasm32 and wasm64 into the package's default-library tree, tested in
# test_wasm_linux.
- name: Build wasm Default Library
continue-on-error: false
working-directory: ${{github.workspace}}/TypeScriptCompilerDefaultLib
shell: bash
env:
TOOL_PATH: ${{github.workspace}}/__build/tslang/ninja/release/bin
LLVM_AR: ${{github.workspace}}/3rdParty/llvm/release/bin/llvm-ar
run: bash ./scripts/build_wasm.sh

- name: Create Tar.GZ of Linux Asset
working-directory: ${{github.workspace}}/__build
shell: sh
Expand Down Expand Up @@ -607,6 +632,127 @@ jobs:
chmod +x ./tests.sh
./tests.sh "$MODEL"

# wasm32 and wasm64 (tslang/test/wasm), against each package: its tslang, the wasm-ld beside it
# and its wasm default library. The tester's tests and the default library's, under -mm=none, rc
# and own, each program run under Node with the JavaScript host; one job per kind of program.
# wasm64 needs Node 24; --require-run fails a test that is only compiled.
test_wasm_windows:
name: Test wasm (Windows, ${{ matrix.programs }} programs)
needs: [defaultlib_commit, build_on_windows]
strategy:
fail-fast: false
matrix:
programs: [release, debug]
runs-on: windows-2025-vs2026
timeout-minutes: 90
env:
TOOL_PATH: ${{ github.workspace }}\__tslang
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 24

- name: Clone Default Library
shell: pwsh
env:
DEFAULTLIB_SHA: ${{ needs.defaultlib_commit.outputs.sha }}
run: |
git clone https://github.com/ASDAlexander77/TypeScriptCompilerDefaultLib.git
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
git -C TypeScriptCompilerDefaultLib checkout --detach $env:DEFAULTLIB_SHA
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

- name: Download Release Asset from Store
uses: actions/download-artifact@v4
with:
name: tslang-windows-asset

- name: Unpack the package
shell: pwsh
run: |
Expand-Archive -Path "${{ env.ASSET_NAME }}-windows-x64.zip" -DestinationPath $env:TOOL_PATH
Remove-Item "${{ env.ASSET_NAME }}-windows-x64.zip"
New-Item -ItemType Directory -Force -Path TypeScriptCompilerDefaultLib\__build | Out-Null
Move-Item -Path (Join-Path $env:TOOL_PATH 'defaultlib') -Destination TypeScriptCompilerDefaultLib\__build\defaultlib -ErrorAction Stop
& (Join-Path $env:TOOL_PATH 'tslang.exe') --version

- name: Test wasm32 and wasm64 (${{ matrix.programs }} programs)
shell: pwsh
working-directory: ${{ github.workspace }}/tslang/test/wasm
env:
MODE: ${{ matrix.programs }}
run: |
$runArgs = @("--tslang=$(Join-Path $env:TOOL_PATH 'tslang.exe')",
"--default-lib-repo=${{ github.workspace }}\TypeScriptCompilerDefaultLib", "--require-run", "-j4")
if ($env:MODE -eq 'debug') { $runArgs += '--debug' }
node run_tests.mjs @runArgs
$code = $LASTEXITCODE
if ($code -ne 0) { Get-Content out\results.txt }
exit $code

test_wasm_linux:
name: Test wasm (${{ matrix.os }}, ${{ matrix.programs }} programs)
needs: [defaultlib_commit, build_on_linux]
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, ubuntu-24.04, ubuntu-26.04]
programs: [release, debug]
runs-on: ${{ matrix.os }}
timeout-minutes: 90
env:
TOOL_PATH: ${{ github.workspace }}/__tslang
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 24

- name: Clone Default Library
shell: bash
env:
DEFAULTLIB_SHA: ${{ needs.defaultlib_commit.outputs.sha }}
run: |
set -e
git clone https://github.com/ASDAlexander77/TypeScriptCompilerDefaultLib.git
git -C TypeScriptCompilerDefaultLib checkout --detach "$DEFAULTLIB_SHA"

- name: Download Release Asset from Store
uses: actions/download-artifact@v4
with:
name: tslang-${{ matrix.os }}-asset

- name: Unpack the package
shell: bash
run: |
set -e
mkdir -p "$TOOL_PATH"
tar -xzf "${{ env.ASSET_NAME }}-${{ matrix.os }}-x64.tar.gz" -C "$TOOL_PATH"
rm "${{ env.ASSET_NAME }}-${{ matrix.os }}-x64.tar.gz"
mkdir -p TypeScriptCompilerDefaultLib/__build
mv "$TOOL_PATH/defaultlib" TypeScriptCompilerDefaultLib/__build/defaultlib
"$TOOL_PATH/tslang" --version

- name: Test wasm32 and wasm64 (${{ matrix.programs }} programs)
shell: bash
working-directory: ${{ github.workspace }}/tslang/test/wasm
env:
MODE: ${{ matrix.programs }}
run: |
debug=""; if [ "$MODE" = debug ]; then debug=--debug; fi
code=0
node run_tests.mjs --tslang="$TOOL_PATH/tslang" \
--default-lib-repo=${{ github.workspace }}/TypeScriptCompilerDefaultLib --require-run -j4 $debug || code=$?
if [ $code -ne 0 ]; then cat out/results.txt; fi
exit $code

# The build jobs above test release programs. The debug ones (TSLANG_TEST_PROGRAMS=debug: debug
# info, no optimization), as a pull request's CI runs them: its own workflows, those legs only.
test_debug_programs_windows:
Expand All @@ -623,7 +769,7 @@ jobs:

create_release:
needs: [build_on_windows, build_on_linux, test_defaultlib_windows, test_defaultlib_linux,
test_debug_programs_windows, test_debug_programs_linux]
test_wasm_windows, test_wasm_linux, test_debug_programs_windows, test_debug_programs_linux]
name: Create Release
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 2 additions & 0 deletions tslang/test/wasm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
out*/
wasm/
10 changes: 10 additions & 0 deletions docs/how/wasm/test/README.md → tslang/test/wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ the test is listed as NATIVE and not counted as a failure: it is something `-mm=
yet. Native ctest runs only a few tests under own, but the whole corpus under none and rc, so under
those two models every wasm compile error counts as a failure.

## In CI

Every pull request runs both suites on wasm32 and wasm64 under none, rc and own, on Windows and
Linux: the exe leg of each build job, with its kind of program (release, or `--debug`), against a
wasm default library that job builds from TypeScriptCompilerDefaultLib's main with the compiler it
just built (`.github/workflows/cmake-test-release-*.yml`). A release builds the wasm default library
into each package and tests the package's compiler, `wasm-ld` and library the same way, release and
debug (`test_wasm_*` in `create-release.yml`). CI passes `--require-run`: on Node 24, which wasm64
needs, a test that is only compiled fails.

## In a browser

Put the `.wasm` files in `wasm\`, serve this folder over HTTP (e.g. `npx http-server .`) and open
Expand Down
Loading
Loading