Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add assert-cli tests for wasm-pack #61

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ install:
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
- rustc -V
- cargo -V
- cargo install wasm-bindgen-cli

build: false

Expand Down
152 changes: 152 additions & 0 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
toml = "0.4"

[dev-dependencies]
assert_cli = "0.5"
16 changes: 16 additions & 0 deletions tests/assert_cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
extern crate assert_cli;

#[test]
fn check_output_pass() {
assert_cli::Assert::main_binary()
.with_args(&["init", "tests/fixtures/assert-cli"])
.stdout()
.contains(":-) Done in")
.stdout()
.contains(":-) Your WASM pkg is ready to publish at tests/fixtures/assert-cli/pkg")
.stderr()
.contains("Finished dev [unoptimized + debuginfo] target(s) in")
.stderr()
.contains("Running `target/debug/wasm-pack init tests/fixtures/assert-cli`")
.unwrap();
}
140 changes: 140 additions & 0 deletions tests/fixtures/assert-cli/Cargo.lock

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

13 changes: 13 additions & 0 deletions tests/fixtures/assert-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "assert-cli-wasm"
description = "an example rust->wasm crate"
version = "0.1.0"
authors = ["Michael Gattozzi <mgattozzi@gmail.com>"]
license = "WTFPL"
repository = "https://github.com/ashleygwilliams/wasm-pack"

[lib]
crate-type = ["cdylib"]

[dependencies]
wasm-bindgen = "0.1.0"
2 changes: 2 additions & 0 deletions tests/fixtures/assert-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# assert-cli-wasm
> an example rust -> wasm project
15 changes: 15 additions & 0 deletions tests/fixtures/assert-cli/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#![feature(proc_macro)]

extern crate wasm_bindgen;

use wasm_bindgen::prelude::*;

#[wasm_bindgen]
extern {
fn alert(s: &str);
}

#[wasm_bindgen]
pub fn greet(name: &str) {
alert(&format!("Hello, {}!", name));
}