From 568a82729b90312084a055c36f6cb127f46adc68 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Thu, 29 Jul 2021 11:23:49 +0200 Subject: [PATCH 01/41] Run tests for Windows --- .github/workflows/windows.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index ab7b4033..ca39bf70 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -56,3 +56,7 @@ jobs: 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 }} + run: | + cargo test --verbose --workspace --all-features -- GitLab From d66c84d77e9a3d40f5457cbc7dbfc452a001b8b1 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Thu, 29 Jul 2021 11:24:04 +0200 Subject: [PATCH 02/41] Add test to reproduce error --- src/cmd/build.rs | 35 +++++++++++++++++++++++++++++++++++ src/workspace/manifest.rs | 13 +++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/cmd/build.rs b/src/cmd/build.rs index cf2ef906..c5fea31c 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -1109,6 +1109,41 @@ mod tests_ci_only { }) } + #[test] + fn building_contract_with_source_file_in_subfolder_must_work() { + with_new_contract_project(|manifest_path| { + // given + let path = manifest_path.directory().expect("dir must exist"); + let old_path = path.join(Path::new("lib.rs")); + let new_path = path.join(Path::new("srcfoo/lib.rs")); + let new_dir_path = path.join(Path::new("srcfoo")); + eprintln!("old path: {:?}", old_path); + eprintln!("new path: {:?}", new_path); + std::fs::create_dir_all(new_dir_path).expect("creating dir must work"); + std::fs::rename(old_path, new_path).expect("moving must work"); + + let mut manifest = + Manifest::new(manifest_path.clone()).expect("creating manifest must work"); + manifest.set_lib_path("srcfoo/lib.rs"); + manifest.write(&manifest_path); + + // when + let res = super::execute( + &manifest_path, + Verbosity::Default, + BuildMode::default(), + BuildArtifacts::CheckOnly, + UnstableFlags::default(), + OptimizationPasses::default(), + Default::default(), + ); + + // then + assert!(res.is_ok(), "building contract failed!"); + Ok(()) + }) + } + #[test] fn keep_debug_symbols_in_debug_mode() { with_new_contract_project(|manifest_path| { diff --git a/src/workspace/manifest.rs b/src/workspace/manifest.rs index fba2d0b0..c59f3922 100644 --- a/src/workspace/manifest.rs +++ b/src/workspace/manifest.rs @@ -248,6 +248,19 @@ impl Manifest { .insert("name".into(), value::Value::String(name.into()))) } + /// Set the `lib` path to `path`. + #[cfg(feature = "test-ci-only")] + #[cfg(test)] + pub fn set_lib_path(&mut self, path: &str) -> Result> { + Ok(self + .toml + .get_mut("lib") + .ok_or_else(|| anyhow::anyhow!("[lib] section not found"))? + .as_table_mut() + .ok_or_else(|| anyhow::anyhow!("[lib] should be a table"))? + .insert("path".into(), value::Value::String(path.into()))) + } + /// Set `[profile.release]` lto flag pub fn with_profile_release_lto(&mut self, enabled: bool) -> Result<&mut Self> { let lto = self -- GitLab From d71716c0ea8e0f73fba23e344698134024745919 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Thu, 29 Jul 2021 14:24:40 +0200 Subject: [PATCH 03/41] Canonicalize paths in test --- src/cmd/build.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/cmd/build.rs b/src/cmd/build.rs index c5fea31c..b95221dc 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -1114,8 +1114,14 @@ mod tests_ci_only { with_new_contract_project(|manifest_path| { // given let path = manifest_path.directory().expect("dir must exist"); - let old_path = path.join(Path::new("lib.rs")); - let new_path = path.join(Path::new("srcfoo/lib.rs")); + let old_path = path + .join(Path::new("lib.rs")) + .canonicalize() + .expect("canonicalize must work"); + let new_path = path + .join(Path::new("srcfoo/lib.rs")) + .canonicalize() + .expect("canonicalize must work"); let new_dir_path = path.join(Path::new("srcfoo")); eprintln!("old path: {:?}", old_path); eprintln!("new path: {:?}", new_path); @@ -1124,8 +1130,10 @@ mod tests_ci_only { let mut manifest = Manifest::new(manifest_path.clone()).expect("creating manifest must work"); - manifest.set_lib_path("srcfoo/lib.rs"); - manifest.write(&manifest_path); + manifest + .set_lib_path("srcfoo/lib.rs") + .expect("setting lib path must work"); + manifest.write(&manifest_path).expect("writing must work"); // when let res = super::execute( -- GitLab From f0d5123a665a86e0784643168a2caac9e5502207 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Thu, 29 Jul 2021 14:26:20 +0200 Subject: [PATCH 04/41] Revert me: Run only necessary tests --- .github/workflows/windows.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index ca39bf70..084957b6 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -52,11 +52,7 @@ jobs: 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 }} run: | - cargo test --verbose --workspace --all-features + cargo test --verbose --workspace --all-features -- building_contract_with_source_file_in_subfolder_must_work -- GitLab From 3c0deb24538863c2a902fc24539ec03e5f750f11 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Thu, 29 Jul 2021 20:01:46 +0200 Subject: [PATCH 05/41] Join `Path`'s to avoid OS-specific separators --- src/cmd/build.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/cmd/build.rs b/src/cmd/build.rs index b95221dc..19439fab 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -1114,14 +1114,8 @@ mod tests_ci_only { with_new_contract_project(|manifest_path| { // given let path = manifest_path.directory().expect("dir must exist"); - let old_path = path - .join(Path::new("lib.rs")) - .canonicalize() - .expect("canonicalize must work"); - let new_path = path - .join(Path::new("srcfoo/lib.rs")) - .canonicalize() - .expect("canonicalize must work"); + let old_path = path.join(Path::new("lib.rs")); + let new_path = path.join(Path::new("srcfoo")).join(Path::new("lib.rs")); let new_dir_path = path.join(Path::new("srcfoo")); eprintln!("old path: {:?}", old_path); eprintln!("new path: {:?}", new_path); -- GitLab From 62c6c2661ccd3383ed71b830acda80bd4baa7677 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Thu, 29 Jul 2021 20:23:41 +0200 Subject: [PATCH 06/41] Revert me: Debug output --- .github/workflows/windows.yml | 2 +- src/cmd/build.rs | 7 ++++++- src/crate_metadata.rs | 1 + src/util.rs | 4 +++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 084957b6..4d06b31d 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -55,4 +55,4 @@ jobs: - name: Run tests on {{ matrix.platform }}-${{ matrix.toolchain }} run: | - cargo test --verbose --workspace --all-features -- building_contract_with_source_file_in_subfolder_must_work + RUST_LOG=debug cargo test --verbose --workspace --all-features -- building_contract_with_source_file_in_subfolder_must_work diff --git a/src/cmd/build.rs b/src/cmd/build.rs index 19439fab..31fdcad3 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -195,6 +195,7 @@ fn exec_cargo_for_wasm_target( verbosity: Verbosity, unstable_flags: &UnstableFlags, ) -> Result<()> { + eprintln!("exec_cargo_for_wasm_target"); util::assert_channel()?; // set linker args via RUSTFLAGS. @@ -218,6 +219,7 @@ fn exec_cargo_for_wasm_target( if build_mode == BuildMode::Debug { args.push("--features=ink_env/ink-debug"); } + eprintln!("invoke cargo"); util::invoke_cargo(command, &args, manifest_path.directory(), verbosity)?; Ok(()) @@ -591,8 +593,10 @@ pub(crate) fn execute( optimization_passes: OptimizationPasses, keep_debug_symbols: bool, ) -> Result { + eprintln!("collecting"); let crate_metadata = CrateMetadata::collect(manifest_path)?; + eprintln!("asserting"); assert_compatible_ink_dependencies(manifest_path, verbosity)?; if build_mode == BuildMode::Debug { assert_debug_mode_supported(&crate_metadata.ink_version)?; @@ -1130,9 +1134,10 @@ mod tests_ci_only { manifest.write(&manifest_path).expect("writing must work"); // when + eprintln!("executing"); let res = super::execute( &manifest_path, - Verbosity::Default, + Verbosity::Verbose, // Make it Default again BuildMode::default(), BuildArtifacts::CheckOnly, UnstableFlags::default(), diff --git a/src/crate_metadata.rs b/src/crate_metadata.rs index 9b47b7d1..51a29396 100644 --- a/src/crate_metadata.rs +++ b/src/crate_metadata.rs @@ -54,6 +54,7 @@ impl CrateMetadata { .expect("lib name not found") .name .replace("-", "_"); + eprintln!("lib_name {:?}", lib_name); let absolute_manifest_path = manifest_path.absolute_directory()?; let absolute_workspace_root = metadata.workspace_root.canonicalize()?; diff --git a/src/util.rs b/src/util.rs index 9d6e7021..85b5f6ac 100644 --- a/src/util.rs +++ b/src/util.rs @@ -120,7 +120,9 @@ pub mod tests { .expect("temporary directory creation failed"); // catch test panics in order to clean up temp dir which will be very large - f(&tmp_dir.path().canonicalize().unwrap()).expect("Error executing test with tmp dir") + let path = tmp_dir.path().canonicalize().expect("canonicalize-ing must work"); + eprintln!("path: {:?}", path); + f(&path).expect("Error executing test with tmp dir") } /// Global counter to generate unique contract names in `with_new_contract_project`. -- GitLab From 373c2cbacf70acbda8317f1b175481c2f5330a87 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Thu, 29 Jul 2021 20:27:03 +0200 Subject: [PATCH 07/41] Fix workflow --- .github/workflows/windows.yml | 4 +++- src/util.rs | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 4d06b31d..69abe9a7 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -55,4 +55,6 @@ jobs: - name: Run tests on {{ matrix.platform }}-${{ matrix.toolchain }} run: | - RUST_LOG=debug cargo test --verbose --workspace --all-features -- building_contract_with_source_file_in_subfolder_must_work + cargo test --verbose --workspace --all-features -- building_contract_with_source_file_in_subfolder_must_work + env: + RUST_LOG: debug diff --git a/src/util.rs b/src/util.rs index 85b5f6ac..3eed5b1c 100644 --- a/src/util.rs +++ b/src/util.rs @@ -120,7 +120,10 @@ pub mod tests { .expect("temporary directory creation failed"); // catch test panics in order to clean up temp dir which will be very large - let path = tmp_dir.path().canonicalize().expect("canonicalize-ing must work"); + let path = tmp_dir + .path() + .canonicalize() + .expect("canonicalize-ing must work"); eprintln!("path: {:?}", path); f(&path).expect("Error executing test with tmp dir") } -- GitLab From f185af5ea39d0760db54c6c0ac3139f78401eb66 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Thu, 29 Jul 2021 21:01:17 +0200 Subject: [PATCH 08/41] Revert me: Debugging --- src/cmd/build.rs | 4 ++++ src/util.rs | 3 +++ src/workspace/mod.rs | 3 +++ 3 files changed, 10 insertions(+) diff --git a/src/cmd/build.rs b/src/cmd/build.rs index 31fdcad3..1f3b9df0 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -206,6 +206,7 @@ fn exec_cargo_for_wasm_target( ); let cargo_build = |manifest_path: &ManifestPath| { + eprintln!("cargo build"); let target_dir = &crate_metadata.target_directory; let target_dir = format!("--target-dir={}", target_dir.to_string_lossy()); let mut args = vec![ @@ -221,11 +222,13 @@ fn exec_cargo_for_wasm_target( } eprintln!("invoke cargo"); util::invoke_cargo(command, &args, manifest_path.directory(), verbosity)?; + eprintln!("invoked cargo"); Ok(()) }; if unstable_flags.original_manifest { + eprintln!("original manifest"); maybe_println!( verbosity, "{} {}", @@ -235,6 +238,7 @@ fn exec_cargo_for_wasm_target( ); cargo_build(&crate_metadata.manifest_path)?; } else { + eprintln!("workspace"); Workspace::new(&crate_metadata.cargo_meta, &crate_metadata.root_package.id)? .with_root_package_manifest(|manifest| { manifest diff --git a/src/util.rs b/src/util.rs index 3eed5b1c..a79b7097 100644 --- a/src/util.rs +++ b/src/util.rs @@ -50,6 +50,8 @@ where P: AsRef, { let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".to_string()); + eprintln!("cargo {:?}", cargo); + eprintln!("args {:?}", args); let mut cmd = Command::new(cargo); if let Some(path) = working_dir { log::debug!("Setting cargo working dir to '{}'", path.as_ref().display()); @@ -64,6 +66,7 @@ where Verbosity::Default => &mut cmd, }; + eprintln!("invoking cargo {:?}", cmd); log::info!("Invoking cargo: {:?}", cmd); let child = cmd diff --git a/src/workspace/mod.rs b/src/workspace/mod.rs index 733e8700..1e298bc0 100644 --- a/src/workspace/mod.rs +++ b/src/workspace/mod.rs @@ -47,6 +47,7 @@ pub struct Workspace { impl Workspace { /// Create a new Workspace from the supplied cargo metadata. pub fn new(metadata: &CargoMetadata, root_package: &PackageId) -> Result { + eprintln!("workspace new"); let member_manifest = |package_id: &PackageId| -> Result<(PackageId, (Package, Manifest))> { let package = metadata .packages @@ -72,6 +73,7 @@ impl Workspace { if !members.contains_key(root_package) { anyhow::bail!("The root package should be a workspace member") } + eprintln!("workspace end"); Ok(Workspace { workspace_root: metadata.workspace_root.clone().into(), @@ -90,6 +92,7 @@ impl Workspace { where F: FnOnce(&mut Manifest) -> Result<()>, { + eprintln!("with_root_package_manifest"); let root_package_manifest = self .members .get_mut(&self.root_package) -- GitLab From b415aae1ba1f0404c33edd5894676b5482ee681e Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Thu, 29 Jul 2021 21:36:42 +0200 Subject: [PATCH 09/41] Windows debugging --- .github/workflows/windows.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 69abe9a7..688cc0e1 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -53,6 +53,14 @@ jobs: wasm-opt --version cargo -vV + cargo run -- contract --version + cargo run -- contract new foobar + echo "[workspace]" >> foobar/Cargo.toml + mkdir foobar\srcfoo + mv foobar/lib.rs foobar\srcfoo\lib.rs + ((Get-Content -path foobar\Cargo.toml -Raw) -replace 'lib.rs','srcfoo/lib.rs') | Set-Content -Path foobar\Cargo.toml + cargo run -- contract build --manifest-path=foobar/Cargo.toml + - name: Run tests on {{ matrix.platform }}-${{ matrix.toolchain }} run: | cargo test --verbose --workspace --all-features -- building_contract_with_source_file_in_subfolder_must_work -- GitLab From 0ef9d49da77c66e5cb53cc226198a5c59545d0be Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Thu, 29 Jul 2021 21:56:03 +0200 Subject: [PATCH 10/41] More debugging --- .github/workflows/windows.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 688cc0e1..cd3a6c43 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -58,11 +58,6 @@ jobs: echo "[workspace]" >> foobar/Cargo.toml mkdir foobar\srcfoo mv foobar/lib.rs foobar\srcfoo\lib.rs - ((Get-Content -path foobar\Cargo.toml -Raw) -replace 'lib.rs','srcfoo/lib.rs') | Set-Content -Path foobar\Cargo.toml + ((Get-Content -path foobar\Cargo.toml -Raw) -replace 'lib.rs','srcfoo\lib.rs') | Set-Content -Path foobar\Cargo.toml + Get-Content -path foobar\Cargo.toml -Raw cargo run -- contract build --manifest-path=foobar/Cargo.toml - - - name: Run tests on {{ matrix.platform }}-${{ matrix.toolchain }} - run: | - cargo test --verbose --workspace --all-features -- building_contract_with_source_file_in_subfolder_must_work - env: - RUST_LOG: debug -- GitLab From 96b404a0107063368ffcaadf50348522a9c4d88d Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Thu, 29 Jul 2021 22:00:23 +0200 Subject: [PATCH 11/41] Debugging --- .github/workflows/windows.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index cd3a6c43..c11b64ff 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -58,6 +58,7 @@ jobs: echo "[workspace]" >> foobar/Cargo.toml mkdir foobar\srcfoo mv foobar/lib.rs foobar\srcfoo\lib.rs - ((Get-Content -path foobar\Cargo.toml -Raw) -replace 'lib.rs','srcfoo\lib.rs') | Set-Content -Path foobar\Cargo.toml + ((Get-Content -path foobar\Cargo.toml -Raw) -replace 'lib.rs','srcfoo/lib.rs') | Set-Content -Path foobar\Cargo.toml Get-Content -path foobar\Cargo.toml -Raw + cargo run --manifest-path=foobar/Cargo.toml cargo run -- contract build --manifest-path=foobar/Cargo.toml -- GitLab From 8ba0529853dc7ad9757315185dada06ca68037ee Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Thu, 29 Jul 2021 22:05:44 +0200 Subject: [PATCH 12/41] 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 c11b64ff..5a373c9d 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -60,5 +60,5 @@ jobs: mv foobar/lib.rs foobar\srcfoo\lib.rs ((Get-Content -path foobar\Cargo.toml -Raw) -replace 'lib.rs','srcfoo/lib.rs') | Set-Content -Path foobar\Cargo.toml Get-Content -path foobar\Cargo.toml -Raw - cargo run --manifest-path=foobar/Cargo.toml + cargo check --manifest-path=foobar/Cargo.toml cargo run -- contract build --manifest-path=foobar/Cargo.toml -- GitLab From 9e0786fd906cdfa69373843251278e5d4b2d19ba Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Thu, 29 Jul 2021 22:13:58 +0200 Subject: [PATCH 13/41] Add nightly --- .github/workflows/windows.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 5a373c9d..6ab7da9f 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -53,12 +53,12 @@ jobs: wasm-opt --version cargo -vV - cargo run -- contract --version - cargo run -- contract new foobar + cargo +nightly run -- contract --version + cargo +nightly run -- contract new foobar echo "[workspace]" >> foobar/Cargo.toml mkdir foobar\srcfoo mv foobar/lib.rs foobar\srcfoo\lib.rs ((Get-Content -path foobar\Cargo.toml -Raw) -replace 'lib.rs','srcfoo/lib.rs') | Set-Content -Path foobar\Cargo.toml Get-Content -path foobar\Cargo.toml -Raw - cargo check --manifest-path=foobar/Cargo.toml - cargo run -- contract build --manifest-path=foobar/Cargo.toml + cargo +nightly check --manifest-path=foobar/Cargo.toml + cargo +nightly run -- contract build --manifest-path=foobar/Cargo.toml -- GitLab From d26eab1cb28103dfe8830643fc5b7cc80f872517 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Thu, 29 Jul 2021 22:18:09 +0200 Subject: [PATCH 14/41] Debugging --- .github/workflows/windows.yml | 5 ++++- src/util.rs | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 6ab7da9f..8cdc022d 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -61,4 +61,7 @@ jobs: ((Get-Content -path foobar\Cargo.toml -Raw) -replace 'lib.rs','srcfoo/lib.rs') | Set-Content -Path foobar\Cargo.toml Get-Content -path foobar\Cargo.toml -Raw cargo +nightly check --manifest-path=foobar/Cargo.toml - cargo +nightly run -- contract build --manifest-path=foobar/Cargo.toml + + cd foobar + cargo +nightly run -- contract check + cargo +nightly run -- contract build diff --git a/src/util.rs b/src/util.rs index a79b7097..651e9429 100644 --- a/src/util.rs +++ b/src/util.rs @@ -55,6 +55,7 @@ where let mut cmd = Command::new(cargo); if let Some(path) = working_dir { log::debug!("Setting cargo working dir to '{}'", path.as_ref().display()); + eprintln!("setting current dir to {:?}", path); cmd.current_dir(path); } -- GitLab From 9cd9e8a98e650ae3bb4951524703fe46e59713f3 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Thu, 29 Jul 2021 22:20:29 +0200 Subject: [PATCH 15/41] Debugging --- src/util.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util.rs b/src/util.rs index 651e9429..6a61f596 100644 --- a/src/util.rs +++ b/src/util.rs @@ -55,7 +55,7 @@ where let mut cmd = Command::new(cargo); if let Some(path) = working_dir { log::debug!("Setting cargo working dir to '{}'", path.as_ref().display()); - eprintln!("setting current dir to {:?}", path); + eprintln!("setting current dir to {:?}", path.as_ref().display()); cmd.current_dir(path); } -- GitLab From 0775bc361f98f56d79fe9d39673a49a4e6c2b270 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Thu, 29 Jul 2021 22:26:24 +0200 Subject: [PATCH 16/41] Debugging --- .github/workflows/windows.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 8cdc022d..c3946e58 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -62,6 +62,5 @@ jobs: Get-Content -path foobar\Cargo.toml -Raw cargo +nightly check --manifest-path=foobar/Cargo.toml - cd foobar - cargo +nightly run -- contract check - cargo +nightly run -- contract build + cargo +nightly run -- contract check --manifest-path=foobar/Cargo.toml + cargo +nightly run -- contract build --manifest-path=foobar/Cargo.toml -- GitLab From 8aea04ef4d705a9b764f59737642303c5827bcd8 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Thu, 29 Jul 2021 22:37:22 +0200 Subject: [PATCH 17/41] Debugging --- .github/workflows/windows.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index c3946e58..e70ce4bc 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -56,9 +56,9 @@ jobs: cargo +nightly run -- contract --version cargo +nightly run -- contract new foobar echo "[workspace]" >> foobar/Cargo.toml - mkdir foobar\srcfoo - mv foobar/lib.rs foobar\srcfoo\lib.rs - ((Get-Content -path foobar\Cargo.toml -Raw) -replace 'lib.rs','srcfoo/lib.rs') | Set-Content -Path foobar\Cargo.toml + mkdir foobar\src + mv foobar/lib.rs foobar\src\lib.rs + ((Get-Content -path foobar\Cargo.toml -Raw) -replace 'lib.rs','src/lib.rs') | Set-Content -Path foobar\Cargo.toml Get-Content -path foobar\Cargo.toml -Raw cargo +nightly check --manifest-path=foobar/Cargo.toml -- GitLab From d86a2b0f8ac59ec7ff77479a7a3b93c9995cdf45 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Thu, 29 Jul 2021 22:53:29 +0200 Subject: [PATCH 18/41] Debugging --- .github/workflows/windows.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index e70ce4bc..d1bea744 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -60,7 +60,8 @@ jobs: mv foobar/lib.rs foobar\src\lib.rs ((Get-Content -path foobar\Cargo.toml -Raw) -replace 'lib.rs','src/lib.rs') | Set-Content -Path foobar\Cargo.toml Get-Content -path foobar\Cargo.toml -Raw - cargo +nightly check --manifest-path=foobar/Cargo.toml - cargo +nightly run -- contract check --manifest-path=foobar/Cargo.toml - cargo +nightly run -- contract build --manifest-path=foobar/Cargo.toml + cargo +nightly install --path . + cd foobar + cargo +nightly run -- contract check + cargo +nightly run -- contract build -- GitLab From fbd6d4c753bba2799dbfed1d7ecac2189fd1717a Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Aug 2021 07:38:45 +0200 Subject: [PATCH 19/41] Fix commands --- .github/workflows/windows.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index d1bea744..09998870 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -63,5 +63,5 @@ jobs: cargo +nightly install --path . cd foobar - cargo +nightly run -- contract check - cargo +nightly run -- contract build + cargo +nightly contract check + cargo +nightly contract build -- GitLab From 8d0b509a3e2d115a2919d5c3d7847b7061865664 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Aug 2021 07:50:34 +0200 Subject: [PATCH 20/41] Debug path --- src/workspace/manifest.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/workspace/manifest.rs b/src/workspace/manifest.rs index c59f3922..d1f885b6 100644 --- a/src/workspace/manifest.rs +++ b/src/workspace/manifest.rs @@ -407,7 +407,8 @@ impl Manifest { // Rewrite `[lib] path = /path/to/lib.rs` if let Some(lib) = self.toml.get_mut("lib") { - rewrite_path(lib, "lib", "src/lib.rs")?; + eprintln!("------rewriting path to src/lib.rs"); + rewrite_path(lib, "lib", "src\lib.rs")?; } // Rewrite `[[bin]] path = /path/to/main.rs` -- GitLab From 1add78e1b694df2d9f3d162ac699c638ad32a3da Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Aug 2021 07:54:13 +0200 Subject: [PATCH 21/41] Debug path --- src/workspace/manifest.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/workspace/manifest.rs b/src/workspace/manifest.rs index d1f885b6..03383eca 100644 --- a/src/workspace/manifest.rs +++ b/src/workspace/manifest.rs @@ -408,7 +408,7 @@ impl Manifest { // Rewrite `[lib] path = /path/to/lib.rs` if let Some(lib) = self.toml.get_mut("lib") { eprintln!("------rewriting path to src/lib.rs"); - rewrite_path(lib, "lib", "src\lib.rs")?; + rewrite_path(lib, "lib", "src\\lib.rs")?; } // Rewrite `[[bin]] path = /path/to/main.rs` -- GitLab From 2e2f2d07a4d6b8a4a12cb01b15f2bbffeae564d5 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Aug 2021 08:12:53 +0200 Subject: [PATCH 22/41] Debug path --- src/workspace/manifest.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/workspace/manifest.rs b/src/workspace/manifest.rs index 03383eca..4bfd4cbb 100644 --- a/src/workspace/manifest.rs +++ b/src/workspace/manifest.rs @@ -372,6 +372,7 @@ impl Manifest { if path.is_relative() { let lib_abs = abs_dir.join(path); log::debug!("Rewriting {} to '{}'", value_id, lib_abs.display()); + eprintln!("Rewriting {} to '{}'", value_id, lib_abs.display()); *existing_path = value::Value::String(lib_abs.to_string_lossy().into()) } Ok(()) @@ -384,9 +385,11 @@ impl Manifest { match table.get_mut("path") { Some(existing_path) => { + eprintln!("to_absolute {}", existing_path); to_absolute(format!("[{}]/path", table_section), existing_path) } None => { + eprintln!("using default path"); let default_path = PathBuf::from(default); if !default_path.exists() { anyhow::bail!( -- GitLab From bcb4d5a50e307e06c694f1ab9dfd2f1214d4fe09 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Aug 2021 08:27:29 +0200 Subject: [PATCH 23/41] Debug path --- src/workspace/manifest.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/workspace/manifest.rs b/src/workspace/manifest.rs index 4bfd4cbb..99e38c0f 100644 --- a/src/workspace/manifest.rs +++ b/src/workspace/manifest.rs @@ -371,8 +371,8 @@ impl Manifest { let path = PathBuf::from(path_str); if path.is_relative() { let lib_abs = abs_dir.join(path); - log::debug!("Rewriting {} to '{}'", value_id, lib_abs.display()); - eprintln!("Rewriting {} to '{}'", value_id, lib_abs.display()); + log::debug!("Rewriting {} to '{}'", value_id, lib_abs.as_os_str()); + eprintln!("Rewriting {} to '{}'", value_id, lib_abs.as_os_str()); *existing_path = value::Value::String(lib_abs.to_string_lossy().into()) } Ok(()) -- GitLab From 7de5e6604361e1f21f05650f1a10fc51965921e1 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Aug 2021 08:33:44 +0200 Subject: [PATCH 24/41] Debug path --- src/workspace/manifest.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/workspace/manifest.rs b/src/workspace/manifest.rs index 99e38c0f..161ee106 100644 --- a/src/workspace/manifest.rs +++ b/src/workspace/manifest.rs @@ -371,9 +371,9 @@ impl Manifest { let path = PathBuf::from(path_str); if path.is_relative() { let lib_abs = abs_dir.join(path); - log::debug!("Rewriting {} to '{}'", value_id, lib_abs.as_os_str()); - eprintln!("Rewriting {} to '{}'", value_id, lib_abs.as_os_str()); - *existing_path = value::Value::String(lib_abs.to_string_lossy().into()) + log::debug!("Rewriting {} to '{}'", value_id, lib_abs.as_os_str().to_string_lossy()); + eprintln!("Rewriting {} to '{}'", value_id, lib_abs.as_os_str().to_string_lossy()); + *existing_path = value::Value::String(lib_abs.as_os_str().to_string_lossy().into()) } Ok(()) }; -- GitLab From a2433571d7c24798bc68d2a3aa4ae2ca5d96f7d0 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Aug 2021 08:44:14 +0200 Subject: [PATCH 25/41] Debug path --- src/workspace/manifest.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/workspace/manifest.rs b/src/workspace/manifest.rs index 161ee106..c65ce388 100644 --- a/src/workspace/manifest.rs +++ b/src/workspace/manifest.rs @@ -365,14 +365,17 @@ impl Manifest { .expect("The manifest path is a file path so has a parent; qed"); let to_absolute = |value_id: String, existing_path: &mut value::Value| -> Result<()> { + eprintln!("in to_absolute"); let path_str = existing_path .as_str() .ok_or_else(|| anyhow::anyhow!("{} should be a string", value_id))?; let path = PathBuf::from(path_str); if path.is_relative() { + eprintln!("path is relative"); let lib_abs = abs_dir.join(path); + eprintln!("--'{:?}'", lib_abs.as_os_str()); log::debug!("Rewriting {} to '{}'", value_id, lib_abs.as_os_str().to_string_lossy()); - eprintln!("Rewriting {} to '{}'", value_id, lib_abs.as_os_str().to_string_lossy()); + eprintln!("--Rewriting {} to '{}'", value_id, lib_abs.as_os_str().to_string_lossy()); *existing_path = value::Value::String(lib_abs.as_os_str().to_string_lossy().into()) } Ok(()) -- GitLab From d2f4c863f304fc255c41d2c430429b546a93500e Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Aug 2021 08:56:21 +0200 Subject: [PATCH 26/41] Debug path --- src/workspace/manifest.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/workspace/manifest.rs b/src/workspace/manifest.rs index c65ce388..082c598e 100644 --- a/src/workspace/manifest.rs +++ b/src/workspace/manifest.rs @@ -369,7 +369,9 @@ impl Manifest { let path_str = existing_path .as_str() .ok_or_else(|| anyhow::anyhow!("{} should be a string", value_id))?; - let path = PathBuf::from(path_str); + eprinltn!("path: {:?}", OsString::from(path_str)); + eprinltn!("path: {:?}", OsString::from(path_str).as_os_str()); + let path = PathBuf::from(OsString::from(path_str)); if path.is_relative() { eprintln!("path is relative"); let lib_abs = abs_dir.join(path); -- GitLab From c3360334ed6f2b64d8721280e2e4a8ba1033ebc2 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Aug 2021 09:02:17 +0200 Subject: [PATCH 27/41] Debug path --- src/workspace/manifest.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/workspace/manifest.rs b/src/workspace/manifest.rs index 082c598e..519bb54b 100644 --- a/src/workspace/manifest.rs +++ b/src/workspace/manifest.rs @@ -21,6 +21,7 @@ use crate::OptimizationPasses; use std::convert::TryFrom; use std::{ + ffi::OsString, collections::HashSet, fs, path::{Path, PathBuf}, @@ -369,8 +370,8 @@ impl Manifest { let path_str = existing_path .as_str() .ok_or_else(|| anyhow::anyhow!("{} should be a string", value_id))?; - eprinltn!("path: {:?}", OsString::from(path_str)); - eprinltn!("path: {:?}", OsString::from(path_str).as_os_str()); + eprintln!("path: {:?}", OsString::from(path_str)); + eprintln!("path: {:?}", OsString::from(path_str).as_os_str()); let path = PathBuf::from(OsString::from(path_str)); if path.is_relative() { eprintln!("path is relative"); -- GitLab From 7a8416e477c7f399c4efe5aca8c12459d7cb8d10 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Aug 2021 09:12:05 +0200 Subject: [PATCH 28/41] Debug path --- src/workspace/manifest.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/workspace/manifest.rs b/src/workspace/manifest.rs index 519bb54b..0969fb59 100644 --- a/src/workspace/manifest.rs +++ b/src/workspace/manifest.rs @@ -370,9 +370,10 @@ impl Manifest { let path_str = existing_path .as_str() .ok_or_else(|| anyhow::anyhow!("{} should be a string", value_id))?; + #[cfg(windows)] + let path_str = path_str.replace("/", "\\").to_str(); eprintln!("path: {:?}", OsString::from(path_str)); - eprintln!("path: {:?}", OsString::from(path_str).as_os_str()); - let path = PathBuf::from(OsString::from(path_str)); + let path = PathBuf::from(path_str); if path.is_relative() { eprintln!("path is relative"); let lib_abs = abs_dir.join(path); -- GitLab From 7ef3f972ce50c234cbdc57f3da7e61b91e86d49d Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Aug 2021 09:17:33 +0200 Subject: [PATCH 29/41] Debug path --- src/workspace/manifest.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/workspace/manifest.rs b/src/workspace/manifest.rs index 0969fb59..f22f63ae 100644 --- a/src/workspace/manifest.rs +++ b/src/workspace/manifest.rs @@ -371,7 +371,7 @@ impl Manifest { .as_str() .ok_or_else(|| anyhow::anyhow!("{} should be a string", value_id))?; #[cfg(windows)] - let path_str = path_str.replace("/", "\\").to_str(); + let path_str = path_str.replace("/", "\\").as_str(); eprintln!("path: {:?}", OsString::from(path_str)); let path = PathBuf::from(path_str); if path.is_relative() { -- GitLab From 57189400fa5c5e2f65337943c0ee792987f2c7be Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Aug 2021 09:23:25 +0200 Subject: [PATCH 30/41] Debug path --- src/workspace/manifest.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/workspace/manifest.rs b/src/workspace/manifest.rs index f22f63ae..16f5b36f 100644 --- a/src/workspace/manifest.rs +++ b/src/workspace/manifest.rs @@ -371,7 +371,9 @@ impl Manifest { .as_str() .ok_or_else(|| anyhow::anyhow!("{} should be a string", value_id))?; #[cfg(windows)] - let path_str = path_str.replace("/", "\\").as_str(); + let path_str_replaced = path_str.replace("/", "\\"); + #[cfg(windows)] + let path_str = path_str_replaced.as_str(); eprintln!("path: {:?}", OsString::from(path_str)); let path = PathBuf::from(path_str); if path.is_relative() { -- GitLab From 10a9c61b113c66a0588ce1ab500f030602d9415f Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Aug 2021 09:39:59 +0200 Subject: [PATCH 31/41] Debug path --- src/workspace/manifest.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/workspace/manifest.rs b/src/workspace/manifest.rs index 16f5b36f..217c5be6 100644 --- a/src/workspace/manifest.rs +++ b/src/workspace/manifest.rs @@ -366,22 +366,17 @@ impl Manifest { .expect("The manifest path is a file path so has a parent; qed"); let to_absolute = |value_id: String, existing_path: &mut value::Value| -> Result<()> { - eprintln!("in to_absolute"); let path_str = existing_path .as_str() .ok_or_else(|| anyhow::anyhow!("{} should be a string", value_id))?; #[cfg(windows)] - let path_str_replaced = path_str.replace("/", "\\"); - #[cfg(windows)] - let path_str = path_str_replaced.as_str(); - eprintln!("path: {:?}", OsString::from(path_str)); + // On Windows path separators are `\`, hence we need to replace the `/` in + // e.g. `src/lib.rs`. + let path_str = &path_str.replace("/", "\\"); let path = PathBuf::from(path_str); if path.is_relative() { - eprintln!("path is relative"); let lib_abs = abs_dir.join(path); - eprintln!("--'{:?}'", lib_abs.as_os_str()); log::debug!("Rewriting {} to '{}'", value_id, lib_abs.as_os_str().to_string_lossy()); - eprintln!("--Rewriting {} to '{}'", value_id, lib_abs.as_os_str().to_string_lossy()); *existing_path = value::Value::String(lib_abs.as_os_str().to_string_lossy().into()) } Ok(()) -- GitLab From 40ad19fd2213ccf09c17ddc5279c671ff4c2953d Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Aug 2021 09:42:11 +0200 Subject: [PATCH 32/41] Remove eprintln's --- src/cmd/build.rs | 8 -------- src/crate_metadata.rs | 1 - src/util.rs | 5 ----- src/workspace/manifest.rs | 3 --- src/workspace/mod.rs | 3 --- 5 files changed, 20 deletions(-) diff --git a/src/cmd/build.rs b/src/cmd/build.rs index 1f3b9df0..53c993a6 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -195,7 +195,6 @@ fn exec_cargo_for_wasm_target( verbosity: Verbosity, unstable_flags: &UnstableFlags, ) -> Result<()> { - eprintln!("exec_cargo_for_wasm_target"); util::assert_channel()?; // set linker args via RUSTFLAGS. @@ -206,7 +205,6 @@ fn exec_cargo_for_wasm_target( ); let cargo_build = |manifest_path: &ManifestPath| { - eprintln!("cargo build"); let target_dir = &crate_metadata.target_directory; let target_dir = format!("--target-dir={}", target_dir.to_string_lossy()); let mut args = vec![ @@ -220,15 +218,12 @@ fn exec_cargo_for_wasm_target( if build_mode == BuildMode::Debug { args.push("--features=ink_env/ink-debug"); } - eprintln!("invoke cargo"); util::invoke_cargo(command, &args, manifest_path.directory(), verbosity)?; - eprintln!("invoked cargo"); Ok(()) }; if unstable_flags.original_manifest { - eprintln!("original manifest"); maybe_println!( verbosity, "{} {}", @@ -238,7 +233,6 @@ fn exec_cargo_for_wasm_target( ); cargo_build(&crate_metadata.manifest_path)?; } else { - eprintln!("workspace"); Workspace::new(&crate_metadata.cargo_meta, &crate_metadata.root_package.id)? .with_root_package_manifest(|manifest| { manifest @@ -597,10 +591,8 @@ pub(crate) fn execute( optimization_passes: OptimizationPasses, keep_debug_symbols: bool, ) -> Result { - eprintln!("collecting"); let crate_metadata = CrateMetadata::collect(manifest_path)?; - eprintln!("asserting"); assert_compatible_ink_dependencies(manifest_path, verbosity)?; if build_mode == BuildMode::Debug { assert_debug_mode_supported(&crate_metadata.ink_version)?; diff --git a/src/crate_metadata.rs b/src/crate_metadata.rs index 51a29396..9b47b7d1 100644 --- a/src/crate_metadata.rs +++ b/src/crate_metadata.rs @@ -54,7 +54,6 @@ impl CrateMetadata { .expect("lib name not found") .name .replace("-", "_"); - eprintln!("lib_name {:?}", lib_name); let absolute_manifest_path = manifest_path.absolute_directory()?; let absolute_workspace_root = metadata.workspace_root.canonicalize()?; diff --git a/src/util.rs b/src/util.rs index 6a61f596..8ead4939 100644 --- a/src/util.rs +++ b/src/util.rs @@ -50,12 +50,9 @@ where P: AsRef, { let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".to_string()); - eprintln!("cargo {:?}", cargo); - eprintln!("args {:?}", args); let mut cmd = Command::new(cargo); if let Some(path) = working_dir { log::debug!("Setting cargo working dir to '{}'", path.as_ref().display()); - eprintln!("setting current dir to {:?}", path.as_ref().display()); cmd.current_dir(path); } @@ -67,7 +64,6 @@ where Verbosity::Default => &mut cmd, }; - eprintln!("invoking cargo {:?}", cmd); log::info!("Invoking cargo: {:?}", cmd); let child = cmd @@ -128,7 +124,6 @@ pub mod tests { .path() .canonicalize() .expect("canonicalize-ing must work"); - eprintln!("path: {:?}", path); f(&path).expect("Error executing test with tmp dir") } diff --git a/src/workspace/manifest.rs b/src/workspace/manifest.rs index 217c5be6..1c08441c 100644 --- a/src/workspace/manifest.rs +++ b/src/workspace/manifest.rs @@ -389,11 +389,9 @@ impl Manifest { match table.get_mut("path") { Some(existing_path) => { - eprintln!("to_absolute {}", existing_path); to_absolute(format!("[{}]/path", table_section), existing_path) } None => { - eprintln!("using default path"); let default_path = PathBuf::from(default); if !default_path.exists() { anyhow::bail!( @@ -414,7 +412,6 @@ impl Manifest { // Rewrite `[lib] path = /path/to/lib.rs` if let Some(lib) = self.toml.get_mut("lib") { - eprintln!("------rewriting path to src/lib.rs"); rewrite_path(lib, "lib", "src\\lib.rs")?; } diff --git a/src/workspace/mod.rs b/src/workspace/mod.rs index 1e298bc0..733e8700 100644 --- a/src/workspace/mod.rs +++ b/src/workspace/mod.rs @@ -47,7 +47,6 @@ pub struct Workspace { impl Workspace { /// Create a new Workspace from the supplied cargo metadata. pub fn new(metadata: &CargoMetadata, root_package: &PackageId) -> Result { - eprintln!("workspace new"); let member_manifest = |package_id: &PackageId| -> Result<(PackageId, (Package, Manifest))> { let package = metadata .packages @@ -73,7 +72,6 @@ impl Workspace { if !members.contains_key(root_package) { anyhow::bail!("The root package should be a workspace member") } - eprintln!("workspace end"); Ok(Workspace { workspace_root: metadata.workspace_root.clone().into(), @@ -92,7 +90,6 @@ impl Workspace { where F: FnOnce(&mut Manifest) -> Result<()>, { - eprintln!("with_root_package_manifest"); let root_package_manifest = self .members .get_mut(&self.root_package) -- GitLab From 0cfa3d7bd773d99e5e66d230a5337ce8fdc807f2 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Aug 2021 09:48:25 +0200 Subject: [PATCH 33/41] Test should fail --- .github/workflows/windows.yml | 13 +------------ src/util.rs | 6 +----- src/workspace/manifest.rs | 14 +++++--------- 3 files changed, 7 insertions(+), 26 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 09998870..dbecc0c0 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -53,15 +53,4 @@ jobs: wasm-opt --version cargo -vV - cargo +nightly run -- contract --version - cargo +nightly run -- contract new foobar - echo "[workspace]" >> foobar/Cargo.toml - mkdir foobar\src - mv foobar/lib.rs foobar\src\lib.rs - ((Get-Content -path foobar\Cargo.toml -Raw) -replace 'lib.rs','src/lib.rs') | Set-Content -Path foobar\Cargo.toml - Get-Content -path foobar\Cargo.toml -Raw - - cargo +nightly install --path . - cd foobar - cargo +nightly contract check - cargo +nightly contract build + cargo test --verbose --workspace --all-features -- building_contract_with_source_file_in_subfolder_must_work \ No newline at end of file diff --git a/src/util.rs b/src/util.rs index 8ead4939..9d6e7021 100644 --- a/src/util.rs +++ b/src/util.rs @@ -120,11 +120,7 @@ pub mod tests { .expect("temporary directory creation failed"); // catch test panics in order to clean up temp dir which will be very large - let path = tmp_dir - .path() - .canonicalize() - .expect("canonicalize-ing must work"); - f(&path).expect("Error executing test with tmp dir") + f(&tmp_dir.path().canonicalize().unwrap()).expect("Error executing test with tmp dir") } /// Global counter to generate unique contract names in `with_new_contract_project`. diff --git a/src/workspace/manifest.rs b/src/workspace/manifest.rs index 1c08441c..94fbc77d 100644 --- a/src/workspace/manifest.rs +++ b/src/workspace/manifest.rs @@ -19,10 +19,10 @@ use anyhow::{Context, Result}; use super::{metadata, Profile}; use crate::OptimizationPasses; -use std::convert::TryFrom; use std::{ - ffi::OsString, + convert::TryFrom, collections::HashSet, + ffi::OsString, fs, path::{Path, PathBuf}, }; @@ -369,15 +369,11 @@ impl Manifest { let path_str = existing_path .as_str() .ok_or_else(|| anyhow::anyhow!("{} should be a string", value_id))?; - #[cfg(windows)] - // On Windows path separators are `\`, hence we need to replace the `/` in - // e.g. `src/lib.rs`. - let path_str = &path_str.replace("/", "\\"); let path = PathBuf::from(path_str); if path.is_relative() { let lib_abs = abs_dir.join(path); - log::debug!("Rewriting {} to '{}'", value_id, lib_abs.as_os_str().to_string_lossy()); - *existing_path = value::Value::String(lib_abs.as_os_str().to_string_lossy().into()) + log::debug!("Rewriting {} to '{}'", value_id, lib_abs.display()); + *existing_path = value::Value::String(lib_abs.to_string_lossy().into()) } Ok(()) }; @@ -412,7 +408,7 @@ impl Manifest { // Rewrite `[lib] path = /path/to/lib.rs` if let Some(lib) = self.toml.get_mut("lib") { - rewrite_path(lib, "lib", "src\\lib.rs")?; + rewrite_path(lib, "lib", "src/lib.rs")?; } // Rewrite `[[bin]] path = /path/to/main.rs` -- GitLab From 5d729b86789188f17a59cea01ca4d1fddcb478ae Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Aug 2021 10:04:12 +0200 Subject: [PATCH 34/41] Test should run --- .github/workflows/windows.yml | 2 +- src/workspace/manifest.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index dbecc0c0..3a970f75 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -53,4 +53,4 @@ jobs: wasm-opt --version cargo -vV - cargo test --verbose --workspace --all-features -- building_contract_with_source_file_in_subfolder_must_work \ No newline at end of file + cargo test -- building_contract_with_source_file_in_subfolder_must_work \ No newline at end of file diff --git a/src/workspace/manifest.rs b/src/workspace/manifest.rs index 94fbc77d..3c9f4358 100644 --- a/src/workspace/manifest.rs +++ b/src/workspace/manifest.rs @@ -22,7 +22,6 @@ use crate::OptimizationPasses; use std::{ convert::TryFrom, collections::HashSet, - ffi::OsString, fs, path::{Path, PathBuf}, }; @@ -369,6 +368,10 @@ impl Manifest { let path_str = existing_path .as_str() .ok_or_else(|| anyhow::anyhow!("{} should be a string", value_id))?; + #[cfg(windows)] + // On Windows path separators are `\`, hence we need to replace the `/` in + // e.g. `src/lib.rs`. + let path_str = &path_str.replace("/", "\\"); let path = PathBuf::from(path_str); if path.is_relative() { let lib_abs = abs_dir.join(path); -- GitLab From 07fba97b617b3fa08394819025b0ac7420b33526 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Aug 2021 10:13:27 +0200 Subject: [PATCH 35/41] Test should run --- .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 3a970f75..4da9ed18 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -53,4 +53,4 @@ jobs: wasm-opt --version cargo -vV - cargo test -- building_contract_with_source_file_in_subfolder_must_work \ No newline at end of file + cargo test --all-features -- building_contract_with_source_file_in_subfolder_must_work \ No newline at end of file -- GitLab From 326006698703ca34fb186e4a090ec54d1d00d9d7 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Aug 2021 10:28:31 +0200 Subject: [PATCH 36/41] Restore Windows testing --- .github/workflows/windows.yml | 8 +++++++- src/cmd/build.rs | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 4da9ed18..ca39bf70 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -52,5 +52,11 @@ jobs: 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 - cargo test --all-features -- building_contract_with_source_file_in_subfolder_must_work \ No newline at end of file + - name: Run tests on {{ matrix.platform }}-${{ matrix.toolchain }} + run: | + cargo test --verbose --workspace --all-features diff --git a/src/cmd/build.rs b/src/cmd/build.rs index 53c993a6..a1a9f50a 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -1133,7 +1133,7 @@ mod tests_ci_only { eprintln!("executing"); let res = super::execute( &manifest_path, - Verbosity::Verbose, // Make it Default again + Verbosity::default(), BuildMode::default(), BuildArtifacts::CheckOnly, UnstableFlags::default(), -- GitLab From b736ed845135fde189812ed67a83312b6dcc970b Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Aug 2021 10:29:22 +0200 Subject: [PATCH 37/41] Apply `cargo fmt` --- src/workspace/manifest.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/workspace/manifest.rs b/src/workspace/manifest.rs index 3c9f4358..24f47c03 100644 --- a/src/workspace/manifest.rs +++ b/src/workspace/manifest.rs @@ -20,8 +20,8 @@ use super::{metadata, Profile}; use crate::OptimizationPasses; use std::{ - convert::TryFrom, collections::HashSet, + convert::TryFrom, fs, path::{Path, PathBuf}, }; -- GitLab From 7b91af40a02cf435e847ebbb9ae7b38ea89922bd Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Aug 2021 10:32:05 +0200 Subject: [PATCH 38/41] Fix default --- src/cmd/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/build.rs b/src/cmd/build.rs index a1a9f50a..be6f8543 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -1133,7 +1133,7 @@ mod tests_ci_only { eprintln!("executing"); let res = super::execute( &manifest_path, - Verbosity::default(), + Verbosity::Default, BuildMode::default(), BuildArtifacts::CheckOnly, UnstableFlags::default(), -- GitLab From c0582da2d3a446d0f6e765b6d688712889d29f3d Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Aug 2021 10:50:27 +0200 Subject: [PATCH 39/41] Remove debug stuff --- src/cmd/build.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/cmd/build.rs b/src/cmd/build.rs index be6f8543..bafa1d31 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -1114,13 +1114,11 @@ mod tests_ci_only { with_new_contract_project(|manifest_path| { // given let path = manifest_path.directory().expect("dir must exist"); - let old_path = path.join(Path::new("lib.rs")); - let new_path = path.join(Path::new("srcfoo")).join(Path::new("lib.rs")); + let old_lib_path = path.join(Path::new("lib.rs")); + let new_lib_path = path.join(Path::new("srcfoo")).join(Path::new("lib.rs")); let new_dir_path = path.join(Path::new("srcfoo")); - eprintln!("old path: {:?}", old_path); - eprintln!("new path: {:?}", new_path); std::fs::create_dir_all(new_dir_path).expect("creating dir must work"); - std::fs::rename(old_path, new_path).expect("moving must work"); + std::fs::rename(old_lib_path, new_lib_path).expect("moving file must work"); let mut manifest = Manifest::new(manifest_path.clone()).expect("creating manifest must work"); @@ -1130,7 +1128,6 @@ mod tests_ci_only { manifest.write(&manifest_path).expect("writing must work"); // when - eprintln!("executing"); let res = super::execute( &manifest_path, Verbosity::Default, -- GitLab From d18a863761a2683cb9c873dae5012eca53e13555 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Aug 2021 11:23:16 +0200 Subject: [PATCH 40/41] Run tests only `master` --- .github/workflows/windows.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index ca39bf70..6ba95301 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -58,5 +58,8 @@ jobs: 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 -- GitLab From 87797818fe09378be3e48e1d4e8ca5e5766b5096 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 3 Aug 2021 16:18:50 +0200 Subject: [PATCH 41/41] Update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c62a161d..4e68e7b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- Fixed a Windows issue with contract files in sub-folders - [#313](https://github.com/paritytech/cargo-contract/pull/313) + ## [0.13.0] - 2021-07-22 ### Added -- GitLab