[bazel] Initial support to mjsunit tests

No-Try: true
Bug: v8:11234
Change-Id: I2035107dfc1865ab17a6eb654a9a0967d6cac357
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3080575
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76168}
This commit is contained in:
Victor Gomes 2021-08-09 16:08:51 +02:00 committed by V8 LUCI CQ
parent a22d54844f
commit 3dc66c735b
2 changed files with 99 additions and 0 deletions

View File

@ -6,6 +6,7 @@ load("@bazel_skylib//lib:selects.bzl", "selects")
load(
"@v8//:bazel/defs.bzl",
"v8_binary",
"v8_build_config",
"v8_config",
"v8_custom_config",
"v8_raw_flag",
@ -3058,3 +3059,42 @@ v8_binary(
],
deps = [ ":v8" ],
)
# =================================================
# Tests
# =================================================
v8_build_config(
name = "v8_build_config",
)
# Runs mjunit with d8.
py_test(
name = "mjsunit",
size = "medium",
srcs = [
"test/mjsunit/testcfg.py",
"tools/predictable_wrapper.py",
"tools/run-tests.py",
] + glob(["tools/testrunner/**/*.py"]),
args = [
"--no-sorting",
"--nopresubmit",
# TODO(victorgomes): Create a flag to pass the variant in the cmdline.
"--variant=default",
"--outdir bazel-bin",
"mjsunit",
],
data = [
":v8_build_config",
":d8",
"test",
] + glob(["test/**"]) + glob(["tools/**/*.js"]) + glob(["tools/**/*.mjs"]),
main = "tools/run-tests.py",
# TODO(victorgomes): Move this to PY3.
python_version = "PY2",
tags = [
# Disable sanitizers, as they don't work in general in V8.
"nosan",
],
)

View File

@ -237,3 +237,62 @@ v8_mksnapshot = rule(
),
}
)
def _quote(val):
if val[0] == '"' and val[-1] == '"':
fail("String", val, "already quoted")
return '"' + val + '"'
def _kv_bool_pair(k, v):
return _quote(k) + ": " + v
def _json(kv_pairs):
content = "{"
for (k, v) in kv_pairs[:-1]:
content += _kv_bool_pair(k, v) + ", "
(k, v) = kv_pairs[-1]
content += _kv_bool_pair(k, v)
content += "}\n"
return content
# TODO(victorgomes): Create a rule (instead of a macro), that can
# dynamically populate the build config.
def v8_build_config(name):
cpu = _quote("x64")
content = _json([
("current_cpu", cpu),
("dcheck_always_on", "false"),
("is_android", "false"),
("is_asan", "false"),
("is_cfi", "false"),
("is_clang", "true"),
("is_component_build", "false"),
("is_debug", "false"),
("is_full_debug", "false"),
("is_gcov_coverage", "false"),
("is_msan", "false"),
("is_tsan", "false"),
("is_ubsan_vptr", "false"),
("target_cpu", cpu),
("v8_current_cpu", cpu),
("v8_enable_atomic_marking_state", "false"),
("v8_enable_atomic_object_field_writes", "false"),
("v8_enable_concurrent_marking", "false"),
("v8_enable_i18n_support", "true"),
("v8_enable_verify_predictable", "false"),
("v8_enable_verify_csa", "false"),
("v8_enable_lite_mode", "false"),
("v8_enable_runtime_call_stats", "false"),
("v8_enable_pointer_compression", "true"),
("v8_enable_pointer_compression_shared_cage", "false"),
("v8_enable_third_party_heap", "false"),
("v8_enable_webassembly", "false"),
("v8_control_flow_integrity", "false"),
("v8_enable_single_generation", "false"),
("v8_target_cpu", cpu),
])
native.genrule(
name = name,
outs = [name + ".json"],
cmd = "echo '" + content + "' > \"$@\"",
)