-
Notifications
You must be signed in to change notification settings - Fork 120
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
Bring test-ci-only
back
#180
Changes from all commits
1a1d679
2926b4d
271696e
0c36a12
1b2cb32
55ecc69
4f24000
4643627
fed87ab
9254d0d
16a3f38
67d1101
d2bf1dd
723c9b2
6257e49
cc82610
7e378be
56c488f
c9c4d09
49319f8
02bc6f8
c00e7c6
d8827bc
d2720c1
defe20d
81bdd0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -430,6 +430,9 @@ pub(crate) fn execute_with_crate_metadata( | |
"Building cargo project".bright_green().bold() | ||
); | ||
build_cargo_project(&crate_metadata, build_artifact, verbosity, unstable_flags)?; | ||
if build_artifact == BuildArtifacts::CheckOnly { | ||
return Ok((None, None)); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This early return is needed because the next step would otherwise try to post-process the contract. But check does not actually create a contract. Without this change
|
||
maybe_println!( | ||
verbosity, | ||
" {} {}", | ||
|
@@ -456,7 +459,9 @@ pub(crate) fn execute_with_crate_metadata( | |
#[cfg(feature = "test-ci-only")] | ||
#[cfg(test)] | ||
mod tests_ci_only { | ||
use crate::{cmd, util::tests::with_tmp_dir, BuildArtifacts, ManifestPath, UnstableFlags}; | ||
use crate::{ | ||
cmd, util::tests::with_tmp_dir, BuildArtifacts, ManifestPath, UnstableFlags, Verbosity, | ||
}; | ||
|
||
#[test] | ||
fn build_template() { | ||
|
@@ -466,30 +471,33 @@ mod tests_ci_only { | |
ManifestPath::new(&path.join("new_project").join("Cargo.toml")).unwrap(); | ||
let res = super::execute( | ||
&manifest_path, | ||
None, | ||
Verbosity::Default, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a required change, actually the code does not build without it. We just didn't notice because the |
||
true, | ||
BuildArtifacts::All, | ||
UnstableFlags::default(), | ||
) | ||
.expect("build failed"); | ||
|
||
// we can't use `/target/ink` here, since this would match | ||
// for `/target` being the root path. but since `ends_with` | ||
// always matches whole path components we can be sure | ||
// the path can never be e.g. `foo_target/ink` -- the assert | ||
// would fail for that. | ||
assert!(res.target_directory.ends_with("target/ink")); | ||
assert!(res.optimization_result.unwrap().optimized_size > 0.0); | ||
// our ci has set `CARGO_TARGET_DIR` to cache artifacts. | ||
// this dir does not include `/target/` as a path, hence | ||
// we can't match for e.g. `foo_project/target/ink`. | ||
// | ||
// we also can't match for `/ink` here, since this would match | ||
// for `/ink` being the root path. | ||
assert!(res.target_directory.ends_with("ink")); | ||
|
||
let optimized_size = res.optimization_result.unwrap().optimized_size; | ||
assert!(optimized_size > 0.0); | ||
|
||
// our optimized contract template should always be below 3k. | ||
assert!(res.optimization_result.unwrap().optimized_size < 3.0); | ||
assert!(optimized_size < 3.0); | ||
|
||
Ok(()) | ||
}) | ||
} | ||
|
||
#[test] | ||
fn check_must_not_create_target_in_project_dir() { | ||
fn check_must_not_output_contract_artifacts_in_project_dir() { | ||
with_tmp_dir(|path| { | ||
// given | ||
cmd::new::execute("new_project", Some(path)).expect("new project creation failed"); | ||
|
@@ -499,7 +507,7 @@ mod tests_ci_only { | |
// when | ||
super::execute( | ||
&manifest_path, | ||
None, | ||
Verbosity::Default, | ||
true, | ||
BuildArtifacts::CheckOnly, | ||
UnstableFlags::default(), | ||
|
@@ -508,8 +516,12 @@ mod tests_ci_only { | |
|
||
// then | ||
assert!( | ||
!project_dir.join("target").exists(), | ||
"found target folder in project directory!" | ||
!project_dir.join("target/ink/new_project.contract").exists(), | ||
"found contract artifact in project directory!" | ||
); | ||
assert!( | ||
!project_dir.join("target/ink/new_project.wasm").exists(), | ||
"found wasm artifact in project directory!" | ||
); | ||
Ok(()) | ||
}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -315,7 +315,7 @@ enum Command { | |
/// Command has been deprecated, use `cargo contract build` instead | ||
#[structopt(name = "generate-metadata")] | ||
GenerateMetadata {}, | ||
/// Check that the code builds as Wasm; does not output any build artifact to the top level `target/` directory | ||
/// Check that the code builds as Wasm; does not output any `<name>.contract` artifact to the `target/` directory | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We invoke
You can verify it locally:
|
||
#[structopt(name = "check")] | ||
Check(CheckCommand), | ||
/// Test the smart contract off-chain | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,7 @@ where | |
Verbosity::Default => &mut cmd, | ||
}; | ||
|
||
log::info!("invoking cargo: {:?}", cmd); | ||
log::info!("Invoking cargo: {:?}", cmd); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just for consistency with the other |
||
|
||
let child = cmd | ||
// capture the stdout to return from this function as bytes | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this from some other PR?