2 个版本
0.1.1 | 2020年3月9日 |
---|---|
0.1.0 | 2020年3月8日 |
在 文件系统 类别中排名 851
12KB
162 代码行
Test262 Harness
ECMAScript 测试套件的 Rust 测试框架。
用法
# Cargo.toml
[dev.dependencies]
test262-harness = "*"
// lib.rs
#[test]
fn test_js() {
let test262_path = "test262";
let harness = Harness::new(test262_path).expect("failed to initialize harness");
for test in harness {
let test = test.unwrap();
println!("running test from {:?}", test.path);
if let Some(id) = &test.desc.id {
println!("id: {}", id);
}
if let Some(id) = &test.desc.esid {
println!("esid: {}", id);
}
if let Some(id) = &test.desc.es5id {
println!("es5id: {}", id);
}
if let Some(id) = &test.desc.es6id {
println!("es6id: {}", id);
}
if let Some(neg) = &test.desc.negative {
print!("expecting test to fail ");
if let Some(except) = &neg.kind {
print!("with {}", except);
}
match &neg.phase {
Phase::Parse => println!("during parsing"),
Phase::Early => println!("after parsing but before evaluation"),
Phase::Resolution => println!("while resolving es6 modules"),
Phase::Runtime => println!("during evaluation"),
}
}
if let Some(info) = &test.desc.info {
println!("info: {}", info);
}
if let Some(desc) = &test.desc.description {
println!("desc: {}", desc);
}
for name in &test.desc.includes {
println!("import {} from the {}/harness directory", name, test262_path);
}
for flag in &test.desc.flags {
match flag {
Flag::OnlyStrict => println!("This test should only run in strict mode"),
Flag::NoStrict => println!("This test should not run in strict mode"),
Flag::Module => println!("This test should be run as a module only"),
Flag::Raw => println!("This test's content should not be altered and run as not-strict only"),
Flag::Async => println!("This test needs to be executed asynchronously"),
Flag::Generated => println!("This test was not written by hand"),
Flag::CanBlockIsFalse => println!("When executing [[CanBlock]] must be false"),
Flag::CanBlockIsTrue => println!("[[CanBlock]] must be true"),
Flag::NonDeterministic => println!("This test can pass in more than one way"),
}
}
for feat in &test.desc.features {
println!("This test is gated by the feature {}", feat);
}
}
}
Test
是与此crate交互的主要方式,它包含测试 test262 文件所需的大量信息。
Test
结构包含3个顶级属性,正在测试的文件的路径、该文件的字符串内容以及元数据,包含在所有文件的多行注释(作为 YAML)前缀中,关于每个 JavaScript 测试的元数据。
依赖项
~2–10MB
~99K SLoC