fork of https://github.com/rustwasm/wasm-pack for the needs of NextGraph.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Liam Murphy ad1778031f
Mark snippets and the bundler target's main file as having side effects
2 years ago
..
utils Mark snippets and the bundler target's main file as having side effects 2 years ago
build.rs Update to Rust 2021 2 years ago
download.rs Update dependencies 2 years ago
generate.rs Update to Rust 2021 2 years ago
license.rs Update to Rust 2021 2 years ago
lockfile.rs Update to Rust 2021 2 years ago
log_level.rs Update dependencies 2 years ago
main.rs Switch from failure to anyhow 2 years ago
manifest.rs Mark snippets and the bundler target's main file as having side effects 2 years ago
readme.rs Update to Rust 2021 2 years ago
stamps.rs fix(command_test): stamps.rs check driver once per day, update RELEASE_CHECKLIST 6 years ago
test.rs Update to Rust 2021 2 years ago
wasm_opt.rs Update to Rust 2021 2 years ago
webdriver.rs Update to Rust 2021 2 years ago

readme.rs

extern crate anyhow;
extern crate wasm_pack;

use std::fs;

use crate::utils::{self, fixture};
use wasm_pack::readme;

#[test]
fn it_copies_a_readme_default_path() {
let fixture = fixture::js_hello_world();
let out_dir = fixture.path.join("pkg");
fs::create_dir(&out_dir).expect("should create pkg directory OK");

assert!(readme::copy_from_crate(&fixture.path, &out_dir).is_ok());

let crate_readme_path = fixture.path.join("README.md");
let pkg_readme_path = out_dir.join("README.md");
println!(
"wasm-pack: should have copied README.md from '{}' to '{}'",
crate_readme_path.display(),
pkg_readme_path.display()
);
assert!(fs::metadata(&crate_readme_path).is_ok());

assert!(fs::metadata(&pkg_readme_path).is_ok());

let crate_readme = utils::file::read_file(&crate_readme_path).unwrap();
let pkg_readme = utils::file::read_file(&pkg_readme_path).unwrap();
assert_eq!(crate_readme, pkg_readme);
}

#[test]
fn it_copies_a_readme_provided_path() {
let fixture = fixture::js_hello_world();
let out_dir = fixture.path.join("pkg");
fs::create_dir(&out_dir).expect("should create pkg directory OK");

assert!(readme::copy_from_crate(&fixture.path, &out_dir).is_ok());
let crate_readme_path = fixture.path.join("README.md");
let pkg_readme_path = out_dir.join("README.md");
println!(
"wasm-pack: should have copied README.md from '{}' to '{}'",
crate_readme_path.display(),
pkg_readme_path.display()
);
assert!(fs::metadata(&crate_readme_path).is_ok());
assert!(fs::metadata(&pkg_readme_path).is_ok());

let crate_readme = utils::file::read_file(&crate_readme_path).unwrap();
let pkg_readme = utils::file::read_file(&pkg_readme_path).unwrap();
assert_eq!(crate_readme, pkg_readme);
}