Skip to content

Commit 6e3cd39

Browse files
committed
add WORKERD_ENABLE_ALL_AUTOGATES env variable
1 parent 987e1dd commit 6e3cd39

37 files changed

+104
-49
lines changed

build/fixtures/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
exports_files(["kj_test.sh"])

build/fixtures/kj_test.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
"$@"

build/kj_test.bzl

+21-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@rules_shell//shell:sh_test.bzl", "sh_test")
2+
13
def kj_test(
24
src,
35
data = [],
@@ -6,8 +8,11 @@ def kj_test(
68
size = "medium",
79
**kwargs):
810
test_name = src.removesuffix(".c++")
11+
binary_name = test_name + "_binary"
12+
913
native.cc_test(
10-
name = test_name,
14+
name = binary_name,
15+
testonly = True,
1116
srcs = [src],
1217
deps = [
1318
"@capnp-cpp//src/kj:kj-test",
@@ -18,6 +23,20 @@ def kj_test(
1823
}),
1924
data = data,
2025
tags = tags,
21-
size = size,
2226
**kwargs
2327
)
28+
sh_test(
29+
name = test_name,
30+
size = size,
31+
srcs = ["//build/fixtures:kj_test.sh"],
32+
data = [binary_name],
33+
args = ["$(location " + binary_name + ")"],
34+
)
35+
sh_test(
36+
name = test_name + "@all-autogates-enabled",
37+
size = size,
38+
env = {"WORKERD_ALL_AUTOGATES": "1"},
39+
srcs = ["//build/fixtures:kj_test.sh"],
40+
data = [binary_name],
41+
args = ["$(location " + binary_name + ")"],
42+
)

src/workerd/api/actor-state-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ struct ActorStateContext: public jsg::Object, public jsg::ContextGlobal {
2929
JSG_DECLARE_ISOLATE_TYPE(ActorStateIsolate, ActorStateContext);
3030

3131
KJ_TEST("v8 serialization version tag hasn't changed") {
32-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
3332
jsg::test::Evaluator<ActorStateContext, ActorStateIsolate> e(v8System);
3433
e.getIsolate().runInLockScope([&](ActorStateIsolate::Lock& isolateLock) {
3534
JSG_WITHIN_CONTEXT_SCOPE(isolateLock,

src/workerd/api/basics-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ JSG_DECLARE_ISOLATE_TYPE(BasicsIsolate,
8787
jsg::TypeWrapperExtension<PromiseWrapper>);
8888

8989
KJ_TEST("EventTarget native listeners work") {
90-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
9190
jsg::test::Evaluator<BasicsContext, BasicsIsolate, CompatibilityFlags::Reader> e(v8System);
9291
e.expectEval("testNativeListenersWork()", "boolean", "true");
9392
}

src/workerd/api/crypto/aes-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ struct CryptoContext: public jsg::Object, public jsg::ContextGlobal {
2525
JSG_DECLARE_ISOLATE_TYPE(CryptoIsolate, CryptoContext);
2626

2727
KJ_TEST("AES-KW key wrap") {
28-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
2928
// Basic test that I wrote when I was seeing heap corruption. Found it easier to iterate on with
3029
// ASAN/valgrind than using our conformance tests with test-runner.
3130
jsg::test::Evaluator<CryptoContext, CryptoIsolate> e(v8System);

src/workerd/api/form-data-memory-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ JSG_DECLARE_ISOLATE_TYPE(HeadersIsolate,
9191
workerd::api::File::Options);
9292

9393
KJ_TEST("FormData memory is accounted for") {
94-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
9594
jsg::test::Evaluator<HeadersContext, HeadersIsolate, CompatibilityFlags::Reader> e(v8System);
9695
e.expectEval("test()", "boolean", "true");
9796
}

src/workerd/api/headers-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ JSG_DECLARE_ISOLATE_TYPE(HeadersIsolate,
9696
jsg::TypeWrapperExtension<PromiseWrapper>);
9797

9898
KJ_TEST("Header memory is accounted for") {
99-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
10099
jsg::test::Evaluator<HeadersContext, HeadersIsolate, CompatibilityFlags::Reader> e(v8System);
101100
e.expectEval("test()", "boolean", "true");
102101
}

src/workerd/api/streams/queue-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ auto getEntry(jsg::Lock& js, auto size) {
106106
#pragma region ValueQueue Tests
107107

108108
KJ_TEST("ValueQueue basics work") {
109-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
110109
preamble([](jsg::Lock& js) {
111110
ValueQueue queue(2);
112111

src/workerd/api/streams/standard-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ jsg::BufferSource toBufferSource(jsg::Lock& js, kj::Array<kj::byte> bytes) {
4141
// Happy Cases
4242

4343
KJ_TEST("ReadableStream read all text (value readable)") {
44-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
4544
preamble([](jsg::Lock& js) {
4645
uint checked = 0;
4746
auto rs = js.alloc<ReadableStream>(newReadableStreamJsController());

src/workerd/io/actor-sqlite-test.c++

+4-2
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,11 @@ KJ_TEST("tells alarm handler to cancel when committed alarm is empty") {
413413
}
414414

415415
KJ_TEST("tells alarm handler to cancel when handler alarm is later than committed alarm") {
416+
// We skip this test if autogates are enabled.
417+
if (util::Autogate::isAllAutogatesEnabled()) {
418+
return;
419+
}
416420
ActorSqliteTest test;
417-
util::Autogate::initAutogateNamesForTest({});
418-
KJ_DEFER(util::Autogate::deinitAutogate());
419421

420422
// Initialize alarm state to 1ms.
421423
test.setAlarm(oneMs);

src/workerd/io/frankenvalue-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ struct TestContext: public ContextGlobalObject {
1818
JSG_DECLARE_ISOLATE_TYPE(TestIsolate, TestContext);
1919

2020
KJ_TEST("Frankenvalue") {
21-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
2221
jsg::test::Evaluator<TestContext, TestIsolate> e(v8System);
2322

2423
e.run([&](jsg::Lock& js) {

src/workerd/io/promise-wrapper-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ JSG_DECLARE_ISOLATE_TYPE(
8484
CaptureThrowIsolate, CaptureThrowContext, jsg::TypeWrapperExtension<workerd::PromiseWrapper>);
8585

8686
KJ_TEST("Async functions capture sync errors with flag") {
87-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
8887
Evaluator<CaptureThrowContext, CaptureThrowIsolate> e(v8System);
8988
e.setCaptureThrowsAsRejections(true);
9089
e.expectEval("test1()", "object", "[object Promise]");

src/workerd/jsg/BUILD.bazel

+1-4
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,7 @@ wd_cc_library(
280280
[kj_test(
281281
src = f,
282282
local_defines = ["JSG_IMPLEMENTATION"],
283-
deps = [
284-
":jsg",
285-
"//src/workerd/util:autogate",
286-
],
283+
deps = [":jsg"],
287284
) for f in glob(
288285
["*-test.c++"],
289286
exclude = [

src/workerd/jsg/buffersource-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ struct BufferSourceContext: public jsg::Object, public jsg::ContextGlobal {
6565
JSG_DECLARE_ISOLATE_TYPE(BufferSourceIsolate, BufferSourceContext);
6666

6767
KJ_TEST("BufferSource works") {
68-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
6968
Evaluator<BufferSourceContext, BufferSourceIsolate> e(v8System);
7069

7170
// By default, a BufferSource handle is created as a DataView

src/workerd/jsg/dom-exception-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ struct DOMExceptionContext: public Object, public ContextGlobal {
1818
JSG_DECLARE_ISOLATE_TYPE(DOMExceptionIsolate, DOMExceptionContext);
1919

2020
KJ_TEST("DOMException's prototype is ErrorPrototype") {
21-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
2221
Evaluator<DOMExceptionContext, DOMExceptionIsolate> e(v8System);
2322
e.expectEval(
2423
"Object.getPrototypeOf(DOMException.prototype) === Error.prototype", "boolean", "true");

src/workerd/jsg/function-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ struct CallbackContext: public ContextGlobalObject {
4444
JSG_DECLARE_ISOLATE_TYPE(CallbackIsolate, CallbackContext, CallbackContext::Frobber, NumberBox);
4545

4646
KJ_TEST("callbacks") {
47-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
4847
Evaluator<CallbackContext, CallbackIsolate> e(v8System);
4948
e.expectEval("callCallback((str, num) => {\n"
5049
" return [typeof str, str, typeof num, num.toString(), 'bar'].join(', ');\n"

src/workerd/jsg/iterator-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ struct GeneratorContext: public Object, public ContextGlobal {
191191
JSG_DECLARE_ISOLATE_TYPE(GeneratorIsolate, GeneratorContext, GeneratorContext::Test);
192192

193193
KJ_TEST("Generator works") {
194-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
195194
Evaluator<GeneratorContext, GeneratorIsolate> e(v8System);
196195

197196
e.expectEval("generatorTest([undefined,2,3])", "number", "2");

src/workerd/jsg/jsg-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ struct TestContext: public ContextGlobalObject {
4343
JSG_DECLARE_ISOLATE_TYPE(TestIsolate, TestContext);
4444

4545
KJ_TEST("hello world") {
46-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
4746
Evaluator<TestContext, TestIsolate> e(v8System);
4847
e.expectEval("'Hello' + ', World!'", "string", "Hello, World!");
4948
}

src/workerd/jsg/jsvalue-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ struct JsValueContext: public ContextGlobalObject {
109109
JSG_DECLARE_ISOLATE_TYPE(JsValueIsolate, JsValueContext, JsValueContext::Foo);
110110

111111
KJ_TEST("simple") {
112-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
113112
Evaluator<JsValueContext, JsValueIsolate> e(v8System);
114113
e.expectEval("takeJsValue(false)", "boolean", "false");
115114
e.expectEval("takeJsString(123)", "string", "123");

src/workerd/jsg/memory-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ void runTest(auto callback) {
4040
}
4141

4242
KJ_TEST("MemoryTracker test") {
43-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
4443
// Verifies that workerd details are included in the heapsnapshot.
4544
// This is not a comprehensive test of the heapsnapshot content,
4645
// it is designed just to make sure that we are, in fact, publishing

src/workerd/jsg/modules-new-test.c++

-2
Original file line numberDiff line numberDiff line change
@@ -752,8 +752,6 @@ KJ_TEST("Bundle shadows built-in") {
752752
// ======================================================================================
753753

754754
KJ_TEST("Attaching a module registry works") {
755-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
756-
757755
PREAMBLE(([&](Lock& js) {
758756
ResolveObserver resolveObserver;
759757
CompilationObserver compilationObserver;

src/workerd/jsg/multiple-typewrappers-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ void expectEval(
137137
}
138138

139139
KJ_TEST("Create a context with a configuration then create a default context with another") {
140-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
141140
capnp::MallocMessageBuilder flagsArena;
142141
auto flags = flagsArena.initRoot<::workerd::CompatibilityFlags>();
143142
auto flagsReader = flags.asReader();

src/workerd/jsg/promise-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ struct PromiseContext: public jsg::Object, public jsg::ContextGlobal {
118118
JSG_DECLARE_ISOLATE_TYPE(PromiseIsolate, PromiseContext);
119119

120120
KJ_TEST("jsg::Promise<T>") {
121-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
122121
Evaluator<PromiseContext, PromiseIsolate> e(v8System);
123122

124123
e.expectEval("setResult(promise.then(i => i + 1 /* oops, i is a string */));\n"

src/workerd/jsg/resource-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ struct BoxContext: public ContextGlobalObject {
2121
JSG_DECLARE_ISOLATE_TYPE(BoxIsolate, BoxContext, NumberBox, BoxBox);
2222

2323
KJ_TEST("constructors and properties") {
24-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
2524
Evaluator<BoxContext, BoxIsolate> e(v8System);
2625
e.expectEval("new NumberBox(123).value", "number", "123");
2726
e.expectEval("new NumberBox(123).boxed.value", "number", "123");

src/workerd/jsg/rtti-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ struct TestResource: public Base {
215215
};
216216

217217
KJ_TEST("resource reference") {
218-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
219218
KJ_EXPECT(tType<TestResource>() ==
220219
"(structure = (name = \"TestResource\", fullyQualifiedName = \"workerd::jsg::rtti::(anonymous namespace)::TestResource\"))");
221220
}

src/workerd/jsg/ser-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ struct SerTestContextV2: public ContextGlobalObject {
238238
JSG_DECLARE_ISOLATE_TYPE(SerTestIsolateV2, SerTestContextV2, SerTestContextV2::Bar);
239239

240240
KJ_TEST("serialization") {
241-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
242241
Evaluator<SerTestContext, SerTestIsolate> e(v8System);
243242

244243
// Test serializing built-in values.

src/workerd/jsg/setup-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ struct EvalContext: public Object, public ContextGlobal {
1515
JSG_DECLARE_ISOLATE_TYPE(EvalIsolate, EvalContext);
1616

1717
KJ_TEST("eval() is blocked") {
18-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
1918
Evaluator<EvalContext, EvalIsolate> e(v8System);
2019
e.expectEval("eval('123')", "throws",
2120
"EvalError: Code generation from strings disallowed for this context");

src/workerd/jsg/struct-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ struct StructContext: public Object, public ContextGlobal {
4242
JSG_DECLARE_ISOLATE_TYPE(StructIsolate, StructContext, NumberBox, TestStruct, SelfStruct);
4343

4444
KJ_TEST("structs") {
45-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
4645
Evaluator<StructContext, StructIsolate> e(v8System);
4746
e.expectEval(
4847
"readTestStruct({str: 'foo', num: 123, box: new NumberBox(456)})", "string", "foo, 123, 456");

src/workerd/jsg/tracing-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ JSG_DECLARE_ISOLATE_TYPE(TraceTestIsolate,
165165
ValueBox);
166166

167167
KJ_TEST("GC collects objects when expected") {
168-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
169168
Evaluator<TraceTestContext, TraceTestIsolate> e(v8System);
170169

171170
// Test that a full GC can collect native objects.

src/workerd/jsg/type-wrapper-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ class TestExtension {
6161
JSG_DECLARE_ISOLATE_TYPE(ExtensionIsolate, ExtensionContext, TypeWrapperExtension<TestExtension>);
6262

6363
KJ_TEST("extensions") {
64-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
6564
Evaluator<ExtensionContext, ExtensionIsolate> e(v8System);
6665
e.expectEval("fromExtensionType(toExtensionType(12.3))", "number", "12");
6766
}

src/workerd/jsg/util-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ struct FreezeContext: public ContextGlobalObject {
2323
JSG_DECLARE_ISOLATE_TYPE(FreezeIsolate, FreezeContext);
2424

2525
KJ_TEST("recursive freezing") {
26-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
2726
Evaluator<FreezeContext, FreezeIsolate> e(v8System);
2827
e.expectEval("let obj = { foo: [ { bar: 1 } ] };\n"
2928
"recursivelyFreeze(obj);\n"

src/workerd/jsg/value-test.c++

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ struct BoolContext: public ContextGlobalObject {
2121
JSG_DECLARE_ISOLATE_TYPE(BoolIsolate, BoolContext);
2222

2323
KJ_TEST("bool") {
24-
util::Autogate::initAutogateNamesForTest({"v8-fast-api"_kj});
2524
Evaluator<BoolContext, BoolIsolate> e(v8System);
2625
e.expectEval("takeBool(false)", "string", "false");
2726
e.expectEval("takeBool(true)", "string", "true");

src/workerd/server/server.c++

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <workerd/io/worker-interface.h>
2626
#include <workerd/io/worker.h>
2727
#include <workerd/server/actor-id-impl.h>
28-
#include <workerd/util/autogate.h>
2928
#include <workerd/util/http-util.h>
3029
#include <workerd/util/mimetype.h>
3130
#include <workerd/util/use-perfetto-categories.h>

src/workerd/server/workerd.c++

+14-2
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,10 @@ class CliMain final: public SchemaFileImpl::ErrorReporter {
754754
"<const-name>", CLI_METHOD(setConstName));
755755
}
756756

757+
bool shouldEnableAllAutogates() {
758+
return getenv("WORKERD_ENABLE_ALL_AUTOGATES") != nullptr;
759+
}
760+
757761
kj::MainBuilder& addServeOrTestOptions(kj::MainBuilder& builder) {
758762
return builder
759763
.addOptionWithArg({'d', "directory-path"}, CLI_METHOD(overrideDirectory), "<name>=<path>",
@@ -1077,7 +1081,11 @@ class CliMain final: public SchemaFileImpl::ErrorReporter {
10771081
mod.setPythonModule("def test():\n pass");
10781082
config = configBuilder.asReader();
10791083
configOwner = kj::mv(builder);
1080-
util::Autogate::initAutogate(getConfig().getAutogates());
1084+
if (shouldEnableAllAutogates()) {
1085+
util::Autogate::initAllAutogates();
1086+
} else {
1087+
util::Autogate::initAutogate(getConfig().getAutogates());
1088+
}
10811089
}
10821090

10831091
void watch() {
@@ -1160,7 +1168,11 @@ class CliMain final: public SchemaFileImpl::ErrorReporter {
11601168
// We'll fail at getConfig() if there are multiple top level Config objects.
11611169
// The error message says that you have to specify which config to use, but
11621170
// it's not clear that there is any mechanism to do that.
1163-
util::Autogate::initAutogate(getConfig().getAutogates());
1171+
if (shouldEnableAllAutogates()) {
1172+
util::Autogate::initAllAutogates();
1173+
} else {
1174+
util::Autogate::initAutogate(getConfig().getAutogates());
1175+
}
11641176
}
11651177

11661178
void setConstName(kj::StringPtr name) {

0 commit comments

Comments
 (0)