From b4381a12406440ded91fdd1b543947873db2f4d8 Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Wed, 8 Jan 2025 11:24:10 +0000 Subject: [PATCH] Run Python tests under asan with leak san disabled. --- build/wd_test.bzl | 13 ++++++++++++- src/cloudflare/internal/test/ai/BUILD.bazel | 8 ++++---- src/cloudflare/internal/test/aig/BUILD.bazel | 8 ++++---- src/cloudflare/internal/test/d1/BUILD.bazel | 8 ++++---- src/cloudflare/internal/test/vectorize/BUILD.bazel | 8 ++++---- src/workerd/server/tests/python/BUILD.bazel | 8 ++++---- 6 files changed, 32 insertions(+), 21 deletions(-) diff --git a/build/wd_test.bzl b/build/wd_test.bzl index f18981e6789..4e511cd68be 100644 --- a/build/wd_test.bzl +++ b/build/wd_test.bzl @@ -63,6 +63,9 @@ def _wd_test_impl(ctx): # can't just specify some other executable with some args. OK, fine, we'll use a script that # just execs its args. if is_windows: + if len(ctx.attr.env): + fail("`env` attribute to _wd_test not supported on Windows") + # Batch script executables must end with ".bat" executable = ctx.actions.declare_file("%s_wd_test.bat" % ctx.label.name) ctx.actions.write( @@ -73,6 +76,12 @@ def _wd_test_impl(ctx): ) else: executable = ctx.outputs.executable + + env_exports_list = [] + for key, value in ctx.attr.env.items(): + env_exports_list.append('export %s="%s"' % (key, value)) + env_exports = "\n".join(env_exports_list) + ctx.actions.write( output = executable, content = """ @@ -80,8 +89,9 @@ def _wd_test_impl(ctx): echo echo \\(cd `pwd` \\&\\& \"$@\" -dTEST_TMPDIR=$TEST_TMPDIR\\) echo + %s exec \"$@\" -dTEST_TMPDIR=$TEST_TMPDIR - """, + """ % env_exports, is_executable = True, ) @@ -105,5 +115,6 @@ _wd_test = rule( "flags": attr.string_list(), "data": attr.label_list(allow_files = True), "_platforms_os_windows": attr.label(default = "@platforms//os:windows"), + "env": attr.string_dict(default = {}), }, ) diff --git a/src/cloudflare/internal/test/ai/BUILD.bazel b/src/cloudflare/internal/test/ai/BUILD.bazel index 085d8be288e..2f4ec2fbf6d 100644 --- a/src/cloudflare/internal/test/ai/BUILD.bazel +++ b/src/cloudflare/internal/test/ai/BUILD.bazel @@ -15,8 +15,8 @@ py_wd_test( "*.js", "*.py", ]), - tags = [ - # TODO(someday): Fix asan failure for this, see https://github.com/cloudflare/workerd/pull/3140#discussion_r1858273318 - "no-asan", - ], + # TODO(someday): Fix leak san failure for this, see https://github.com/cloudflare/workerd/pull/3140#discussion_r1858273318 + env = { + "ASAN_OPTIONS": "detect_leaks=0", + }, ) diff --git a/src/cloudflare/internal/test/aig/BUILD.bazel b/src/cloudflare/internal/test/aig/BUILD.bazel index d7c95c317a3..5f6e4fab619 100644 --- a/src/cloudflare/internal/test/aig/BUILD.bazel +++ b/src/cloudflare/internal/test/aig/BUILD.bazel @@ -15,8 +15,8 @@ py_wd_test( "*.js", "*.py", ]), - tags = [ - # TODO(someday): Fix asan failure for this, see https://github.com/cloudflare/workerd/pull/3140#discussion_r1858273318 - "no-asan", - ], + # TODO(someday): Fix leak san failure for this, see https://github.com/cloudflare/workerd/pull/3140#discussion_r1858273318 + env = { + "ASAN_OPTIONS": "detect_leaks=0", + }, ) diff --git a/src/cloudflare/internal/test/d1/BUILD.bazel b/src/cloudflare/internal/test/d1/BUILD.bazel index 461decb6923..8ff322de756 100644 --- a/src/cloudflare/internal/test/d1/BUILD.bazel +++ b/src/cloudflare/internal/test/d1/BUILD.bazel @@ -24,8 +24,8 @@ py_wd_test( "*.py", "*.js", ]), - tags = [ - # TODO(someday): Fix asan failure for this, see https://github.com/cloudflare/workerd/pull/3140#discussion_r1858273318 - "no-asan", - ], + # TODO(someday): Fix leak san failure for this, see https://github.com/cloudflare/workerd/pull/3140#discussion_r1858273318 + env = { + "ASAN_OPTIONS": "detect_leaks=0", + }, ) diff --git a/src/cloudflare/internal/test/vectorize/BUILD.bazel b/src/cloudflare/internal/test/vectorize/BUILD.bazel index e83c8688bc0..f0788f553cc 100644 --- a/src/cloudflare/internal/test/vectorize/BUILD.bazel +++ b/src/cloudflare/internal/test/vectorize/BUILD.bazel @@ -13,8 +13,8 @@ py_wd_test( "*.py", "*.js", ]), - tags = [ - # TODO(someday): Fix asan failure for this, see https://github.com/cloudflare/workerd/pull/3140#discussion_r1858273318 - "no-asan", - ], + # TODO(someday): Fix leak san failure for this, see https://github.com/cloudflare/workerd/pull/3140#discussion_r1858273318 + env = { + "ASAN_OPTIONS": "detect_leaks=0", + }, ) diff --git a/src/workerd/server/tests/python/BUILD.bazel b/src/workerd/server/tests/python/BUILD.bazel index 47db26c9de4..6ae5e80939a 100644 --- a/src/workerd/server/tests/python/BUILD.bazel +++ b/src/workerd/server/tests/python/BUILD.bazel @@ -30,10 +30,10 @@ py_wd_test("subdirectory") py_wd_test( "sdk", - tags = [ - # TODO(someday): Fix asan failure for this, see https://github.com/cloudflare/workerd/pull/3140#discussion_r1858273318 - "no-asan", - ], + # TODO(someday): Fix leak san failure for this, see https://github.com/cloudflare/workerd/pull/3140#discussion_r1858273318 + env = { + "ASAN_OPTIONS": "detect_leaks=0", + }, ) gen_import_tests(PYODIDE_IMPORTS_TO_TEST)