Skip to content

Commit

Permalink
test: remove #[ignore] from parts of test suite, using `near-worksp…
Browse files Browse the repository at this point in the history
…aces` (#111)
  • Loading branch information
dj8yfo authored Oct 11, 2023
1 parent 7b1002d commit acfcab1
Show file tree
Hide file tree
Showing 8 changed files with 674 additions and 592 deletions.
1,230 changes: 666 additions & 564 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions cargo-near/src/commands/build_command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ pub struct BuildCommand {
#[interactive_clap(long)]
pub doc: bool,
/// Do not generate ABI for the contract
#[interactive_clap(long)]
// #[clap(long, conflicts_with_all = &["doc", "embed-abi"])]
#[interactive_clap(long, conflicts_with_all = &["doc", "embed_abi"])]
pub no_abi: bool,
/// Copy final artifacts to this directory
#[interactive_clap(long)]
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ syn = "1.0"
tempfile = "3.3"
tokio = "1.0"
quote = "1.0"
workspaces = "0.7.0"
near-workspaces = "0.8.0"
zstd = "0.11"
5 changes: 1 addition & 4 deletions integration-tests/tests/build/embed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ use function_name::named;

#[tokio::test]
#[named]
// TODO: remove ignore after near-workspaces-rs supports Rust 1.70+
// https://github.com/near/cargo-near/issues/104
#[ignore]
async fn test_build_embed_abi() -> cargo_near::CliResult {
let build_result = build_fn_with! {
Opts: "--embed-abi";
Expand Down Expand Up @@ -42,7 +39,7 @@ async fn test_build_no_embed_abi() -> cargo_near::CliResult {
}
};

let worker = workspaces::sandbox().await?;
let worker = near_workspaces::sandbox().await?;
let contract = worker.dev_deploy(&build_result.wasm).await?;
let outcome = contract.call("__contract_abi").view().await;
outcome.unwrap_err();
Expand Down
3 changes: 0 additions & 3 deletions integration-tests/tests/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ mod opts;

#[tokio::test]
#[named]
// TODO: remove ignore after near-workspaces-rs supports Rust 1.70+
// https://github.com/near/cargo-near/issues/104
#[ignore]
async fn test_build_simple() -> cargo_near::CliResult {
let build_result = build_fn! {
/// Adds `a` and `b`.
Expand Down
17 changes: 3 additions & 14 deletions integration-tests/tests/build/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ fn test_build_opt_out_dir() -> cargo_near::CliResult {

#[tokio::test]
#[named]
// TODO: remove ignore after near-workspaces-rs supports Rust 1.70+
// https://github.com/near/cargo-near/issues/104
#[ignore]
async fn test_build_opt_release() -> cargo_near::CliResult {
let build_result = build_fn_with! {
Opts: "--release";
Expand All @@ -88,9 +85,6 @@ async fn test_build_opt_release() -> cargo_near::CliResult {

#[tokio::test]
#[named]
// TODO: remove ignore after near-workspaces-rs supports Rust 1.70+
// https://github.com/near/cargo-near/issues/104
#[ignore]
async fn test_build_opt_doc_embed() -> cargo_near::CliResult {
let build_result = build_fn_with! {
Opts: "--doc --embed-abi";
Expand Down Expand Up @@ -118,9 +112,6 @@ async fn test_build_opt_doc_embed() -> cargo_near::CliResult {

#[test]
#[named]
// TODO: remove ignore after near-workspaces-rs supports Rust 1.70+
// https://github.com/near/cargo-near/issues/104
#[ignore]
fn test_build_opt_no_abi_doc() -> cargo_near::CliResult {
fn run_test() -> cargo_near::CliResult {
build_fn_with! {
Expand All @@ -133,19 +124,17 @@ fn test_build_opt_no_abi_doc() -> cargo_near::CliResult {
};
Ok(())
}

assert!(run_test()
.unwrap_err()
.to_string()
.contains("The argument '--no-abi' cannot be used with '--doc'"));
.contains("error: the argument '--no-abi' cannot be used with '--doc'"));

Ok(())
}

#[test]
#[named]
// TODO: remove ignore after near-workspaces-rs supports Rust 1.70+
// https://github.com/near/cargo-near/issues/104
#[ignore]
fn test_build_opt_no_abi_embed() -> cargo_near::CliResult {
fn run_test() -> cargo_near::CliResult {
build_fn_with! {
Expand All @@ -161,7 +150,7 @@ fn test_build_opt_no_abi_embed() -> cargo_near::CliResult {
assert!(run_test()
.unwrap_err()
.to_string()
.contains("The argument '--no-abi' cannot be used with '--embed-abi'"));
.contains("error: the argument '--no-abi' cannot be used with '--embed-abi'"));

Ok(())
}
2 changes: 0 additions & 2 deletions integration-tests/tests/cargo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,6 @@ fn test_dependency_patch() -> cargo_near::CliResult {
Ok(())
}

// TODO: Re-enable when we release 4.1.0
#[ignore]
#[test]
#[named]
fn test_abi_not_a_table() -> cargo_near::CliResult {
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/tests/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use serde_json::json;

/// Utility method to test that the `add` function is available and works as intended
pub async fn test_add(wasm: &[u8]) -> cargo_near::CliResult {
let worker = workspaces::sandbox().await?;
let worker = near_workspaces::sandbox().await?;
let contract = worker.dev_deploy(wasm).await?;
let outcome = contract
.call("add")
Expand All @@ -19,7 +19,7 @@ pub async fn test_add(wasm: &[u8]) -> cargo_near::CliResult {
}

pub async fn fetch_contract_abi(wasm: &[u8]) -> color_eyre::eyre::Result<AbiRoot> {
let worker = workspaces::sandbox().await?;
let worker = near_workspaces::sandbox().await?;
let contract = worker.dev_deploy(wasm).await?;
let outcome = contract.call("__contract_abi").view().await?;
let outcome_json = zstd::decode_all(outcome.result.as_slice())?;
Expand Down

0 comments on commit acfcab1

Please sign in to comment.