Skip to content

Commit

Permalink
Add build test for wasm validator (ampproject#37261)
Browse files Browse the repository at this point in the history
* Add build test for wasm validator

* Show bazel progress

* WIP disable cpp tests

* Revert cpp tests

* Noshow progress
  • Loading branch information
antiphoton authored Apr 12, 2023
1 parent 692237e commit a622b88
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ executors:
docker:
- image: cimg/node:lts-browsers
resource_class: xlarge
jdk-docker-xlarge:
jdk-docker-2xlarge:
docker:
- image: cimg/openjdk:17.0-node
resource_class: xlarge
resource_class: 2xlarge
macos-medium:
macos:
xcode: 13.4.1
Expand Down Expand Up @@ -254,7 +254,7 @@ jobs:
- teardown_vm
validator_tests:
executor:
name: jdk-docker-xlarge
name: jdk-docker-2xlarge
steps:
- setup_vm
- run:
Expand Down
4 changes: 4 additions & 0 deletions build-system/tasks/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ async function validatorCpp() {
'bazel test',
'--repo_env=CC=clang',
"--cxxopt='-std=c++17'",
'--discard_analysis_cache',
'--notrack_incremental_state',
'--nokeep_state_after_build',
'--test_output=errors',
'--ui_event_filters=INFO',
'--noshow_progress',
'--noshow_loading_progress',
'--test_summary=detailed',
'--verbose_failures',
'cpp/engine:validator_test',
'cpp/engine/wasm:validator_js_test',
].join(' ');
execOrDie(bazelCmd, {
cwd: 'validator',
Expand Down
9 changes: 7 additions & 2 deletions validator/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Defaults to optimized build.
build -c opt
# Defaults to compile as fast as possible.
build --compilation_mode fastbuild

# Tested and compiles in llvm.
build --repo_env=CC=clang
Expand All @@ -9,3 +9,8 @@ build --cxxopt='-std=c++17'

# Enabled operator new and operator delete for custom allocators.
build --cxxopt='-fsized-deallocation'

build --cxxopt='-Wno-error=return-type'
build --cxxopt='-Wno-error=unused-but-set-variable'
build --cxxopt='-Wno-error=unused-variable'
build --cxxopt='-Wno-unknown-warning-option'
5 changes: 1 addition & 4 deletions validator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ This is only useful development - e.g. when making changes to
In `amphtml/validator` folder, run

```bash
bazel build --cxxopt='-Wno-error=return-type' \
--cxxopt='-Wno-error=unused-but-set-variable' \
--cxxopt='-Wno-error=unused-variable' \
cpp/engine/wasm:validator_js_bin
bazel build cpp/engine/wasm:validator_js_bin
```

This creates `bazel-bin/cpp/engine/wasm/validator_js_bin.js`, which is
Expand Down
6 changes: 6 additions & 0 deletions validator/cpp/engine/wasm/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Wraps AMP Validator into a WebAssembly library,
# which can be used by javascript files.

load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@emsdk//emscripten_toolchain:wasm_rules.bzl", "wasm_cc_binary")
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_binary", "closure_js_library")

Expand Down Expand Up @@ -72,3 +73,8 @@ closure_js_binary(
":validator_js_lib",
],
)

build_test(
name = "validator_js_test",
targets = [":validator_js_bin"],
)

0 comments on commit a622b88

Please sign in to comment.