// Load the config letmut config: Config =
toml::from_str(&fs::read_to_string("config.toml").expect("failed to read config.toml"))
.expect("invalid config.toml");
// Load the lock file, or default to no pinned commits letmut lock: Lock = if Path::new("config-lock.toml").exists() {
toml::from_str(
&fs::read_to_string("config-lock.toml").expect("failed to read config-lock.toml"),
)
.expect("invalid config-lock.toml")
} else {
Lock::default()
};
// Clean old tests and initialize the repo if it doesn't exist let specs_dir = "specs/";
clean_and_init_dirs(specs_dir);
// Generate the tests letmut successes = Vec::new(); letmut failures = Vec::new();
{ // Change to the `specs/` dir where all the work happens let _cd = change_dir(specs_dir); for repo in &config.repos {
info!("Processing {:#?}", repo);
// Abort if we had a failure if !failures.is_empty() {
warn!("Failed."); for (name, err) in &failures {
warn!("{}: (failure) {:?}", name, err);
}
std::process::exit(1);
}
// Display successful results
info!("Done."); for (name, status) in &successes { let repo = config.find_repo_mut(&name).unwrap();
lock.set_commit(&name, &status.commit_base_hash);
fn build_repo(repo: &Repo, config: &Config, lock: &Lock) -> Result<Status> { let remote_name = &repo.name; let remote_url = &repo.url; let remote_branch = repo.branch.as_ref().map(|x| x.as_str()).unwrap_or("master"); let branch_upstream = format!("{}/{}", repo.name, remote_branch); let branch_base = repo.name.clone();
// Initialize our remote and branches if they don't exist let remotes = run("git", &["remote"])?; if !remotes.lines().any(|x| x == repo.name) {
run("git", &["remote", "add", remote_name, &remote_url])?;
run("git", &["fetch", remote_name])?;
run("git", &["branch", &branch_base, &branch_upstream])?;
}
// Set the upstream to the correct branch
run( "git",
&[ "branch",
&branch_base, "--set-upstream-to",
&branch_upstream,
],
)?;
// Fetch the latest changes for this repo
run("git", &["fetch", remote_name])?;
// Checkout the pinned commit, if any, and get the absolute commit hash let base_treeish = lock.find_commit(&repo.name).unwrap_or(&branch_upstream);
run("git", &["checkout", &branch_base])?;
run("git", &["reset", base_treeish, "--hard"])?; let commit_base_hash = run("git", &["log", "--pretty=%h", "-n", "1"])?
.trim()
.to_owned();
// Try to merge with parent repo, if specified let merged = try_merge_parent(repo, &commit_base_hash)?;
// Exclude files specified from the config and repo letmut excluded_files = Vec::new();
excluded_files.extend_from_slice(&config.excluded_tests);
excluded_files.extend_from_slice(&repo.excluded_tests); let exclude = RegexSetBuilder::new(&excluded_files).build().unwrap();
// Try to build the test suite on this commit. This may fail due to merging // with a parent repo, in which case we will try again in an unmerged state. letmut built = false; match try_build_tests(&exclude) {
Ok(()) => built = true,
Err(err) => warn!("Failed to build tests: {:?}", err),
}; // if try_build_tests(&exclude).is_err() { // if repo.parent.is_some() { // warn!( // "Failed to build interpreter. Retrying on unmerged commit ({})", // &commit_base_hash // ); // run("git", &["reset", &commit_base_hash, "--hard"])?; // built = try_build_tests(&exclude).is_ok(); // } else { // built = false; // } // } // if !built { // warn!("Failed to build interpreter, Won't emit js/html"); // }
// Get the final commit message we ended up on let commit_final_message = run("git", &["log", "--oneline", "-n", "1"])?;
// Compute the source files that changed, and use that to filter the files // we copy over. We can't compare the generated tests, because for a // generated WPT we need to copy both the .js and .html even if only // one of those is different from the master. let tests_changed = find_tests_changed(repo)?;
info!("Changed tests: {:#?}", tests_changed);
// Include the changed tests, specified files, and `harness/` directory letmut included_files = Vec::new();
included_files.extend_from_slice(&tests_changed);
included_files.extend_from_slice(&config.included_tests);
included_files.extend_from_slice(&repo.included_tests);
included_files.push("harness/".to_owned()); let include = RegexSetBuilder::new(&included_files).build().unwrap();
// Copy over all the desired test-suites if !repo.skip_wast {
copy_tests(repo, "test/core", "../tests", "wast", &include, &exclude);
} if built && !repo.skip_js {
copy_tests(repo, "js", "../tests", "js", &include, &exclude);
copy_directives(repo, config)?;
}
let paths = find("./test/core/"); for path in paths { if path.extension() != Some(OsStr::new("wast")) { continue;
}
let stripped_path = path.strip_prefix("./test/core/").unwrap(); let stripped_path_str = stripped_path.to_str().unwrap(); if exclude.is_match(stripped_path_str) { continue;
}
let source = std::fs::read_to_string(&path)?; let script = wast2js::convert(&path, &source)?;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.