Skip to content

Commit 118aae2

Browse files
authored
Use GCZeal in tests when run with debugmozjs (#515)
* Use GCZeal in tests when run with debugmozjs Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * fmt Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
1 parent f7c263b commit 118aae2

13 files changed

+55
-0
lines changed

mozjs/tests/callback.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ fn callback() {
1818
let engine = JSEngine::init().unwrap();
1919
let runtime = Runtime::new(engine.handle());
2020
let context = runtime.cx();
21+
#[cfg(feature = "debugmozjs")]
22+
unsafe {
23+
mozjs::jsapi::SetGCZeal(context, 2, 1);
24+
}
2125
let h_option = OnNewGlobalHookOption::FireOnNewGlobalHook;
2226
let c_option = RealmOptions::default();
2327

mozjs/tests/capture_stack.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ fn capture_stack() {
1616
let engine = JSEngine::init().unwrap();
1717
let runtime = Runtime::new(engine.handle());
1818
let context = runtime.cx();
19+
#[cfg(feature = "debugmozjs")]
20+
unsafe {
21+
mozjs::jsapi::SetGCZeal(context, 2, 1);
22+
}
1923
let h_option = OnNewGlobalHookOption::FireOnNewGlobalHook;
2024
let c_option = RealmOptions::default();
2125

mozjs/tests/enforce_range.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ impl SM {
2424
let engine = JSEngine::init().unwrap();
2525
let rt = Runtime::new(engine.handle());
2626
let cx = rt.cx();
27+
#[cfg(feature = "debugmozjs")]
28+
unsafe {
29+
mozjs::jsapi::SetGCZeal(cx, 2, 1);
30+
}
2731
let h_option = OnNewGlobalHookOption::FireOnNewGlobalHook;
2832
let c_option = RealmOptions::default();
2933
rooted!(in(cx) let global = unsafe {JS_NewGlobalObject(

mozjs/tests/enumerate.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ fn enumerate() {
1717
let engine = JSEngine::init().unwrap();
1818
let runtime = Runtime::new(engine.handle());
1919
let context = runtime.cx();
20+
#[cfg(feature = "debugmozjs")]
21+
unsafe {
22+
mozjs::jsapi::SetGCZeal(context, 2, 1);
23+
}
2024
let h_option = OnNewGlobalHookOption::FireOnNewGlobalHook;
2125
let c_option = RealmOptions::default();
2226

mozjs/tests/evaluate.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ fn evaluate() {
1414
let engine = JSEngine::init().unwrap();
1515
let runtime = Runtime::new(engine.handle());
1616
let context = runtime.cx();
17+
#[cfg(feature = "debugmozjs")]
18+
unsafe {
19+
mozjs::jsapi::SetGCZeal(context, 2, 1);
20+
}
1721
let h_option = OnNewGlobalHookOption::FireOnNewGlobalHook;
1822
let c_option = RealmOptions::default();
1923

mozjs/tests/external_string.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ fn external_string() {
1919
let engine = JSEngine::init().unwrap();
2020
let runtime = Runtime::new(engine.handle());
2121
let context = runtime.cx();
22+
#[cfg(feature = "debugmozjs")]
23+
unsafe {
24+
mozjs::jsapi::SetGCZeal(context, 2, 1);
25+
}
2226
let h_option = OnNewGlobalHookOption::FireOnNewGlobalHook;
2327
let c_option = RealmOptions::default();
2428

mozjs/tests/jsvalue.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ fn jsvalues() {
4040
let engine = JSEngine::init().unwrap();
4141
let runtime = Runtime::new(engine.handle());
4242
let context = runtime.cx();
43+
#[cfg(feature = "debugmozjs")]
44+
unsafe {
45+
mozjs::jsapi::SetGCZeal(context, 2, 1);
46+
}
4347
let h_option = OnNewGlobalHookOption::FireOnNewGlobalHook;
4448
let c_option = RealmOptions::default();
4549

mozjs/tests/panic.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ fn test_panic() {
1717
let engine = JSEngine::init().unwrap();
1818
let runtime = Runtime::new(engine.handle());
1919
let context = runtime.cx();
20+
#[cfg(feature = "debugmozjs")]
21+
unsafe {
22+
mozjs::jsapi::SetGCZeal(context, 2, 1);
23+
}
2024
let h_option = OnNewGlobalHookOption::FireOnNewGlobalHook;
2125
let c_option = RealmOptions::default();
2226

mozjs/tests/property_descriptor.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ fn property_descriptor() {
2121
let engine = JSEngine::init().unwrap();
2222
let runtime = Runtime::new(engine.handle());
2323
let context = runtime.cx();
24+
25+
#[cfg(feature = "debugmozjs")]
26+
unsafe {
27+
mozjs::jsapi::SetGCZeal(context, 2, 1);
28+
}
29+
2430
let h_option = OnNewGlobalHookOption::FireOnNewGlobalHook;
2531
let c_option = RealmOptions::default();
2632

mozjs/tests/runtime.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ fn runtime() {
1717
let engine = JSEngine::init().unwrap();
1818
let runtime = Runtime::new(engine.handle());
1919
let context = runtime.cx();
20+
#[cfg(feature = "debugmozjs")]
21+
unsafe {
22+
mozjs::jsapi::SetGCZeal(context, 2, 1);
23+
}
2024
let h_option = OnNewGlobalHookOption::FireOnNewGlobalHook;
2125
let c_option = RealmOptions::default();
2226

0 commit comments

Comments
 (0)