From a4d435407bf078570ea2af94e05bc79384be6487 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Aug 2021 19:55:08 +0200 Subject: [PATCH 01/11] Debug test --- .github/workflows/windows.yml | 14 +------------- src/cmd/test.rs | 1 + src/util.rs | 3 +++ 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 6ba95301..f8bcd33b 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -48,18 +48,6 @@ jobs: - name: Rust Cache uses: Swatinem/rust-cache@v1.2.0 - - name: Build contract template on ${{ matrix.platform }}-${{ matrix.toolchain }} - run: | - wasm-opt --version - cargo -vV - cargo run -- contract --version - cargo run -- contract new foobar - echo "[workspace]" >> foobar/Cargo.toml - cargo run -- contract build --manifest-path=foobar/Cargo.toml - - name: Run tests on {{ matrix.platform }}-${{ matrix.toolchain }} - # The tests take a long time in the GitHub Actions runner (~30 mins), - # hence we run them only on `master`. - if: github.ref == 'refs/heads/master' run: | - cargo test --verbose --workspace --all-features + cargo test --verbose --all-features -- passing_tests_yield_stdout diff --git a/src/cmd/test.rs b/src/cmd/test.rs index 98b9dae1..372f6c58 100644 --- a/src/cmd/test.rs +++ b/src/cmd/test.rs @@ -66,6 +66,7 @@ pub(crate) fn execute(manifest_path: &ManifestPath, verbosity: Verbosity) -> Res ); let stdout = util::invoke_cargo("test", &[""], manifest_path.directory(), verbosity)?; + eprintln!("after stdout"); Ok(TestResult { stdout, verbosity }) } diff --git a/src/util.rs b/src/util.rs index 9d6e7021..3053dab3 100644 --- a/src/util.rs +++ b/src/util.rs @@ -51,8 +51,10 @@ where { let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".to_string()); let mut cmd = Command::new(cargo); + eprintln!("cmd {:?}", cmd); if let Some(path) = working_dir { log::debug!("Setting cargo working dir to '{}'", path.as_ref().display()); + eprintln!("Setting cargo working dir to '{}'", path.as_ref().display()); cmd.current_dir(path); } @@ -65,6 +67,7 @@ where }; log::info!("Invoking cargo: {:?}", cmd); + eprintln!("Invoking cargo: {:?}", cmd); let child = cmd // capture the stdout to return from this function as bytes -- GitLab From 891d6a7a0ac6c7a79672d902e85e7d45f07c13f9 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Wed, 4 Aug 2021 05:24:04 +0200 Subject: [PATCH 02/11] More debugging --- .github/workflows/windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index f8bcd33b..785958e6 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -50,4 +50,4 @@ jobs: - name: Run tests on {{ matrix.platform }}-${{ matrix.toolchain }} run: | - cargo test --verbose --all-features -- passing_tests_yield_stdout + cargo test --verbose --all-features --workspace -- --nocapture passing_tests_yield_stdout -- GitLab From 44adaec766e4b0f6ff5c0b9cadea4e1bb0b7bdb6 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Wed, 4 Aug 2021 06:45:18 +0200 Subject: [PATCH 03/11] Add debugging info --- .github/workflows/windows.yml | 2 +- src/cmd/build.rs | 9 +++++++-- src/util.rs | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 785958e6..f366cd35 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -50,4 +50,4 @@ jobs: - name: Run tests on {{ matrix.platform }}-${{ matrix.toolchain }} run: | - cargo test --verbose --all-features --workspace -- --nocapture passing_tests_yield_stdout + cargo test --verbose --all-features --workspace -- --nocapture diff --git a/src/cmd/build.rs b/src/cmd/build.rs index bafa1d31..7427852f 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -940,8 +940,13 @@ mod tests_ci_only { // then assert!(res.is_err()); - assert!(format!("{:?}", res) - .starts_with("Err(Your wasm-opt version is 98, but we require a version >= 99.")); + assert!( + format!("{:?}", res).starts_with( + "Err(Your wasm-opt version is 98, but we require a version >= 99." + ), + "Expected a different output, found {:?}", + res + ); Ok(()) }) diff --git a/src/util.rs b/src/util.rs index 3053dab3..04850f02 100644 --- a/src/util.rs +++ b/src/util.rs @@ -79,6 +79,8 @@ where if output.status.success() { Ok(output.stdout) } else { + eprintln!("output stdout: {:?}", output.stdout); + eprintln!("output stderr: {:?}", output.stderr); anyhow::bail!( "`{:?}` failed with exit code: {:?}", cmd, -- GitLab From ae2e33e040a6d9c01e5e1b311a578a4ea91c3ee9 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Wed, 4 Aug 2021 07:52:39 +0200 Subject: [PATCH 04/11] More debugging --- src/cmd/build.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cmd/build.rs b/src/cmd/build.rs index 7427852f..c1dacb5d 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -201,7 +201,10 @@ fn exec_cargo_for_wasm_target( // Currently will override user defined RUSTFLAGS from .cargo/config. See https://github.com/paritytech/cargo-contract/issues/98. std::env::set_var( "RUSTFLAGS", - "-C link-arg=-z -C link-arg=stack-size=65536 -C link-arg=--import-memory", + //#[cfg(not(windows))] + //"-C link-arg=-z -C link-arg=stack-size=65536 -C link-arg=--import-memory", + //#[cfg(windows)] + "-C link-args=-zstack-size=65536,--import-memory", ); let cargo_build = |manifest_path: &ManifestPath| { @@ -218,6 +221,7 @@ fn exec_cargo_for_wasm_target( if build_mode == BuildMode::Debug { args.push("--features=ink_env/ink-debug"); } + //args.push("-- ") util::invoke_cargo(command, &args, manifest_path.directory(), verbosity)?; Ok(()) -- GitLab From 9b9822d83f953af217559e6aaf3394ca80575e07 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Wed, 4 Aug 2021 08:16:21 +0200 Subject: [PATCH 05/11] More debugging --- src/cmd/build.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cmd/build.rs b/src/cmd/build.rs index c1dacb5d..061191b1 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -199,13 +199,15 @@ fn exec_cargo_for_wasm_target( // set linker args via RUSTFLAGS. // Currently will override user defined RUSTFLAGS from .cargo/config. See https://github.com/paritytech/cargo-contract/issues/98. + /* std::env::set_var( "RUSTFLAGS", //#[cfg(not(windows))] //"-C link-arg=-z -C link-arg=stack-size=65536 -C link-arg=--import-memory", //#[cfg(windows)] - "-C link-args=-zstack-size=65536,--import-memory", + "-C link-args=--import-memory,-zstack-size=65536", ); + */ let cargo_build = |manifest_path: &ManifestPath| { let target_dir = &crate_metadata.target_directory; @@ -221,7 +223,7 @@ fn exec_cargo_for_wasm_target( if build_mode == BuildMode::Debug { args.push("--features=ink_env/ink-debug"); } - //args.push("-- ") + args.push("-- -C link-arg=-z -C link-arg=stack-size=65536 -C link-arg=--import-memory"); util::invoke_cargo(command, &args, manifest_path.directory(), verbosity)?; Ok(()) @@ -248,7 +250,7 @@ fn exec_cargo_for_wasm_target( } // clear RUSTFLAGS - std::env::remove_var("RUSTFLAGS"); + //std::env::remove_var("RUSTFLAGS"); Ok(()) } -- GitLab From b7ded0ce315c2d5e5f708a857b52975f7af1d5ec Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Wed, 4 Aug 2021 08:29:25 +0200 Subject: [PATCH 06/11] More debugging --- src/cmd/build.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/cmd/build.rs b/src/cmd/build.rs index 061191b1..e3d04543 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -199,7 +199,6 @@ fn exec_cargo_for_wasm_target( // set linker args via RUSTFLAGS. // Currently will override user defined RUSTFLAGS from .cargo/config. See https://github.com/paritytech/cargo-contract/issues/98. - /* std::env::set_var( "RUSTFLAGS", //#[cfg(not(windows))] @@ -207,7 +206,6 @@ fn exec_cargo_for_wasm_target( //#[cfg(windows)] "-C link-args=--import-memory,-zstack-size=65536", ); - */ let cargo_build = |manifest_path: &ManifestPath| { let target_dir = &crate_metadata.target_directory; @@ -223,7 +221,7 @@ fn exec_cargo_for_wasm_target( if build_mode == BuildMode::Debug { args.push("--features=ink_env/ink-debug"); } - args.push("-- -C link-arg=-z -C link-arg=stack-size=65536 -C link-arg=--import-memory"); + //args.push("-- -C link-arg=-z -C link-arg=stack-size=65536 -C link-arg=--import-memory"); util::invoke_cargo(command, &args, manifest_path.directory(), verbosity)?; Ok(()) @@ -250,7 +248,7 @@ fn exec_cargo_for_wasm_target( } // clear RUSTFLAGS - //std::env::remove_var("RUSTFLAGS"); + std::env::remove_var("RUSTFLAGS"); Ok(()) } -- GitLab From 60ea78d33e95f76c5885aefbd4c4a27e47af0acc Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Wed, 4 Aug 2021 08:46:54 +0200 Subject: [PATCH 07/11] More debugging --- src/cmd/build.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cmd/build.rs b/src/cmd/build.rs index e3d04543..e7d43d4a 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -201,10 +201,11 @@ fn exec_cargo_for_wasm_target( // Currently will override user defined RUSTFLAGS from .cargo/config. See https://github.com/paritytech/cargo-contract/issues/98. std::env::set_var( "RUSTFLAGS", + "-C link-arg=-zstack-size=65536 -C link-arg=--import-memory", //#[cfg(not(windows))] //"-C link-arg=-z -C link-arg=stack-size=65536 -C link-arg=--import-memory", //#[cfg(windows)] - "-C link-args=--import-memory,-zstack-size=65536", + //"-C link-args=--import-memory,-zstack-size=65536", ); let cargo_build = |manifest_path: &ManifestPath| { -- GitLab From 22c1d173812b5dfc231d1d5db0edef69051302ae Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Wed, 4 Aug 2021 09:24:47 +0200 Subject: [PATCH 08/11] Remove debugging code --- src/cmd/build.rs | 5 ----- src/cmd/test.rs | 1 - src/util.rs | 5 ----- 3 files changed, 11 deletions(-) diff --git a/src/cmd/build.rs b/src/cmd/build.rs index e7d43d4a..c43f9006 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -202,10 +202,6 @@ fn exec_cargo_for_wasm_target( std::env::set_var( "RUSTFLAGS", "-C link-arg=-zstack-size=65536 -C link-arg=--import-memory", - //#[cfg(not(windows))] - //"-C link-arg=-z -C link-arg=stack-size=65536 -C link-arg=--import-memory", - //#[cfg(windows)] - //"-C link-args=--import-memory,-zstack-size=65536", ); let cargo_build = |manifest_path: &ManifestPath| { @@ -222,7 +218,6 @@ fn exec_cargo_for_wasm_target( if build_mode == BuildMode::Debug { args.push("--features=ink_env/ink-debug"); } - //args.push("-- -C link-arg=-z -C link-arg=stack-size=65536 -C link-arg=--import-memory"); util::invoke_cargo(command, &args, manifest_path.directory(), verbosity)?; Ok(()) diff --git a/src/cmd/test.rs b/src/cmd/test.rs index 372f6c58..98b9dae1 100644 --- a/src/cmd/test.rs +++ b/src/cmd/test.rs @@ -66,7 +66,6 @@ pub(crate) fn execute(manifest_path: &ManifestPath, verbosity: Verbosity) -> Res ); let stdout = util::invoke_cargo("test", &[""], manifest_path.directory(), verbosity)?; - eprintln!("after stdout"); Ok(TestResult { stdout, verbosity }) } diff --git a/src/util.rs b/src/util.rs index 04850f02..9d6e7021 100644 --- a/src/util.rs +++ b/src/util.rs @@ -51,10 +51,8 @@ where { let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".to_string()); let mut cmd = Command::new(cargo); - eprintln!("cmd {:?}", cmd); if let Some(path) = working_dir { log::debug!("Setting cargo working dir to '{}'", path.as_ref().display()); - eprintln!("Setting cargo working dir to '{}'", path.as_ref().display()); cmd.current_dir(path); } @@ -67,7 +65,6 @@ where }; log::info!("Invoking cargo: {:?}", cmd); - eprintln!("Invoking cargo: {:?}", cmd); let child = cmd // capture the stdout to return from this function as bytes @@ -79,8 +76,6 @@ where if output.status.success() { Ok(output.stdout) } else { - eprintln!("output stdout: {:?}", output.stdout); - eprintln!("output stderr: {:?}", output.stderr); anyhow::bail!( "`{:?}` failed with exit code: {:?}", cmd, -- GitLab From 844720b25102afcc87905631247545fdcbb3a077 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Wed, 4 Aug 2021 09:25:58 +0200 Subject: [PATCH 09/11] Restore workflow --- .github/workflows/windows.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index f366cd35..0e170a71 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -48,6 +48,18 @@ jobs: - name: Rust Cache uses: Swatinem/rust-cache@v1.2.0 + - name: Build contract template on ${{ matrix.platform }}-${{ matrix.toolchain }} + run: | + wasm-opt --version + cargo -vV + cargo run -- contract --version + cargo run -- contract new foobar + echo "[workspace]" >> foobar/Cargo.toml + cargo run -- contract build --manifest-path=foobar/Cargo.toml + - name: Run tests on {{ matrix.platform }}-${{ matrix.toolchain }} + # The tests take a long time in the GitHub Actions runner (~30 mins), + # hence we run them only on `master`. + if: github.ref == 'refs/heads/master' run: | - cargo test --verbose --all-features --workspace -- --nocapture + cargo test --verbose --workspace --all-features \ No newline at end of file -- GitLab From 79849d1ba9618523de43b234645368e2abcad159 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Wed, 4 Aug 2021 09:26:34 +0200 Subject: [PATCH 10/11] Restore workflow --- .github/workflows/windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 0e170a71..6ba95301 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -62,4 +62,4 @@ jobs: # hence we run them only on `master`. if: github.ref == 'refs/heads/master' run: | - cargo test --verbose --workspace --all-features \ No newline at end of file + cargo test --verbose --workspace --all-features -- GitLab From 5cbb4605e8032746690f27bd5270b8c6ef87ddfd Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Wed, 4 Aug 2021 09:28:41 +0200 Subject: [PATCH 11/11] Test more sub-commands --- .github/workflows/windows.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 6ba95301..3e16d3ca 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -56,6 +56,8 @@ jobs: cargo run -- contract new foobar echo "[workspace]" >> foobar/Cargo.toml cargo run -- contract build --manifest-path=foobar/Cargo.toml + cargo run -- contract check --manifest-path=foobar/Cargo.toml + cargo run -- contract test --manifest-path=foobar/Cargo.toml - name: Run tests on {{ matrix.platform }}-${{ matrix.toolchain }} # The tests take a long time in the GitHub Actions runner (~30 mins), -- GitLab