Skip to content

Commit

Permalink
Added some tester implementations needed for async/await testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Razican committed Jun 9, 2022
1 parent ee6b955 commit 681e6f6
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions boa_engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ dyn-clone = "1.0.5"
once_cell = "1.12.0"
tap = "1.0.1"
icu_locale_canonicalizer = { version = "0.6.0", features = ["serde"], optional = true }
icu_locid = { version = "0.6.0", features = ["serde"], optional = true }
icu_locid = { version = "0.6.0", features = ["serde"], optional = true }
icu_datetime = { version = "0.6.0", features = ["serde"], optional = true }
icu_plurals = { version = "0.6.0", features = ["serde"], optional = true }
icu_provider = { version = "0.6.0", optional = true }
icu_testdata = {version = "0.6.0", optional = true}
icu_testdata = { version = "0.6.0", optional = true }
sys-locale = { version = "0.2.0", optional = true }

[dev-dependencies]
Expand Down
1 change: 1 addition & 0 deletions boa_tester/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ publish = false
[dependencies]
boa_engine = { path = "../boa_engine", features = ["intl"], version = "0.14.0" }
boa_interner = { path = "../boa_interner", version = "0.14.0" }
boa_gc = { path = "../boa_gc", version = "0.14.0" }
structopt = "0.3.26"
serde = { version = "1.0.137", features = ["derive"] }
serde_yaml = "0.8.24"
Expand Down
6 changes: 4 additions & 2 deletions boa_tester/src/exec/js262.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub(super) fn init(context: &mut Context) -> JsObject {
.function(create_realm, "createRealm", 0)
.function(detach_array_buffer, "detachArrayBuffer", 2)
.function(eval_script, "evalScript", 1)
.function(gc, "gc", 0)
.property("global", global_obj, Attribute::default())
// .property("agent", agent, Attribute::default())
.build();
Expand Down Expand Up @@ -99,7 +100,8 @@ fn eval_script(_this: &JsValue, args: &[JsValue], context: &mut Context) -> JsRe
/// Wraps the host's garbage collection invocation mechanism, if such a capability exists.
/// Must throw an exception if no capability exists. This is necessary for testing the
/// semantics of any feature that relies on garbage collection, e.g. the `WeakRef` API.
#[allow(dead_code)]
#[allow(clippy::unnecessary_wraps)]
fn gc(_this: &JsValue, _: &[JsValue], _context: &mut Context) -> JsResult<JsValue> {
todo!()
boa_gc::force_collect();
Ok(JsValue::undefined())
}
10 changes: 8 additions & 2 deletions boa_tester/src/exec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,18 @@ impl Test {
}

context
.eval(&harness.assert.as_ref())
.eval(harness.assert.as_ref())
.map_err(|e| format!("could not run assert.js:\n{}", e.display()))?;
context
.eval(&harness.sta.as_ref())
.eval(harness.sta.as_ref())
.map_err(|e| format!("could not run sta.js:\n{}", e.display()))?;

if self.flags.contains(TestFlags::ASYNC) {
context
.eval(harness.doneprint_handle.as_ref())
.map_err(|e| format!("could not run doneprintHandle.js:\n{}", e.display()))?;
}

for include in self.includes.iter() {
context
.eval(
Expand Down
1 change: 1 addition & 0 deletions boa_tester/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ fn run_test_suite(
struct Harness {
assert: Box<str>,
sta: Box<str>,
doneprint_handle: Box<str>,
includes: FxHashMap<Box<str>, Box<str>>,
}

Expand Down
6 changes: 5 additions & 1 deletion boa_tester/src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub(super) fn read_harness(test262_path: &Path) -> anyhow::Result<Harness> {
let file_name = entry.file_name();
let file_name = file_name.to_string_lossy();

if file_name == "assert.js" || file_name == "sta.js" {
if file_name == "assert.js" || file_name == "sta.js" || file_name == "doneprintHandle.js" {
continue;
}

Expand All @@ -102,10 +102,14 @@ pub(super) fn read_harness(test262_path: &Path) -> anyhow::Result<Harness> {
let sta = fs::read_to_string(test262_path.join("harness/sta.js"))
.context("error reading harnes/sta.js")?
.into_boxed_str();
let doneprint_handle = fs::read_to_string(test262_path.join("harness/doneprintHandle.js"))
.context("error reading harnes/doneprintHandle.js")?
.into_boxed_str();

Ok(Harness {
assert,
sta,
doneprint_handle,
includes,
})
}
Expand Down

0 comments on commit 681e6f6

Please sign in to comment.