-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add qjs unittest and test workflow
- Loading branch information
Showing
8 changed files
with
125 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
test --test_output=errors | ||
common --enable_bzlmod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
*.sh export-ignore | ||
.bazel* export-ignore | ||
.git* export-ignore | ||
e2e export-ignore | ||
examples export-ignore | ||
*.sh export-ignore | ||
.bazel* export-ignore | ||
.git* export-ignore | ||
e2e export-ignore | ||
examples export-ignore | ||
quickjs/*_test.bzl export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Used in github workflow `test.yaml` | ||
build --disk_cache=~/.cache/bazel | ||
build --repository_cache=~/.cache/bazel-repo | ||
test --test_env=XDG_CACHE_HOME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
workflow_dispatch: | ||
|
||
env: | ||
XDG_CACHE_HOME: ~/.cache/bazel-repo | ||
|
||
jobs: | ||
pre-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Mount bazel caches | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cache/bazel | ||
~/.cache/bazel-repo | ||
key: bazel-cache-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'WORKSPACE') }} | ||
restore-keys: bazel-cache- | ||
- name: bazel test //:setup | ||
run: > | ||
bazel | ||
--bazelrc=${{ github.workspace }}/.bazelrc | ||
--bazelrc=${{ github.workspace }}/.github/workflows/ci.bazelrc | ||
test //:setup | ||
test: | ||
needs: ["pre-test"] | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
bazelversion: | ||
- 6.4.0 | ||
- 7.0.0 | ||
folder: | ||
- "." | ||
- "e2e" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Mount bazel caches | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cache/bazel | ||
~/.cache/bazel-repo | ||
key: bazel-cache-${{ hashFiles('**/BUILD.bazel', '**/*.bzl', 'WORKSPACE') }} | ||
restore-keys: bazel-cache- | ||
- name: bazel version | ||
working-directory: ${{ matrix.folder }} | ||
env: | ||
USE_BAZEL_VERSION: ${{ matrix.bazelversion }} | ||
run: bazel version | ||
- name: bazel test //... | ||
working-directory: ${{ matrix.folder }} | ||
env: | ||
USE_BAZEL_VERSION: ${{ matrix.bazelversion }} | ||
run: > | ||
bazel | ||
--bazelrc=${{ github.workspace }}/.bazelrc | ||
--bazelrc=${{ github.workspace }}/.github/workflows/ci.bazelrc | ||
test //... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,6 @@ stardoc_with_diff_test( | |
bzl_library_target = "//quickjs:qjs", | ||
) | ||
|
||
update_docs() | ||
update_docs( | ||
tags = ["manual"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"qjs test suite" | ||
|
||
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") | ||
load("@bazel_skylib//rules:write_file.bzl", "write_file") | ||
load(":qjs.bzl", "qjs_binary") | ||
|
||
def _create_launcher_test_impl(ctx): | ||
env = analysistest.begin(ctx) | ||
launcher_file = analysistest.target_actions(env)[0].outputs.to_list()[0].basename | ||
asserts.equals(env, launcher_file, "qjs_test_launcher.sh") | ||
return analysistest.end(env) | ||
|
||
create_launcher_test = analysistest.make(_create_launcher_test_impl) | ||
|
||
def qjs_test_suite(name = "qjs_test"): | ||
create_launcher_test( | ||
name = "create_launcher_test", | ||
target_under_test = ":qjs_test", | ||
) | ||
|
||
write_file( | ||
name = "index_js", | ||
out = "index.js", | ||
content = [ | ||
"print('Hello, World!');", | ||
], | ||
) | ||
|
||
qjs_binary( | ||
name = name, | ||
entry_point = ":index.js", | ||
) |