Start implementing a test suite for the CLI

We have very few tests today so this starts to add the basics of a test
suite which compiles Cargo projects on-the-fly which will hopefully help
us bolster the amount of assertions we can make about the output.
This commit is contained in:
Alex Crichton
2019-02-28 11:37:08 -08:00
parent 6edb40a807
commit 362777fc75
7 changed files with 319 additions and 9 deletions

View File

@ -67,6 +67,9 @@ pub struct Context<'a> {
/// All package.json dependencies we've learned about so far
pub package_json_read: HashSet<&'a str>,
/// A map of the name of npm dependencies we've loaded so far to the path
/// they're defined in as well as their version specification.
pub npm_dependencies: HashMap<String, (&'a str, String)>,
pub anyref: wasm_bindgen_anyref_xform::Context,
@ -2967,8 +2970,7 @@ impl<'a, 'b> SubContext<'a, 'b> {
}
if !self.cx.config.mode.nodejs() && !self.cx.config.mode.bundler() {
bail!("NPM dependencies have been specified in `{}` but \
this is only compatible with the default output of \
`wasm-bindgen` or the `--nodejs` flag");
this is only compatible with the `bundler` and `nodejs` targets");
}
let contents = fs::read_to_string(path).context(format!("failed to read `{}`", path))?;
let json: serde_json::Value = serde_json::from_str(&contents)?;