diff --git a/Cargo.lock b/Cargo.lock index 65d8d2c412..019ea12e93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1713,7 +1713,7 @@ dependencies = [ ] [[package]] -name = "solidity_testing_smoke" +name = "solidity_testing_sanctuary" version = "0.10.0" dependencies = [ "anyhow", diff --git a/Cargo.toml b/Cargo.toml index ae176f5a4d..81235a48d0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ members = [ "crates/solidity/outputs/npm/crate", "crates/solidity/outputs/npm/package", "crates/solidity/outputs/spec", - "crates/solidity/testing/smoke", + "crates/solidity/testing/sanctuary", "crates/solidity/testing/snapshots", "crates/solidity/testing/utils", ] @@ -58,7 +58,7 @@ solidity_npm_build = { path = "crates/solidity/outputs/npm/build" } solidity_npm_crate = { path = "crates/solidity/outputs/npm/crate" } solidity_npm_package = { path = "crates/solidity/outputs/npm/package" } solidity_spec = { path = "crates/solidity/outputs/spec" } -solidity_testing_smoke = { path = "crates/solidity/testing/smoke" } +solidity_testing_sanctuary = { path = "crates/solidity/testing/sanctuary" } solidity_testing_snapshots = { path = "crates/solidity/testing/snapshots" } solidity_testing_utils = { path = "crates/solidity/testing/utils" } # diff --git a/crates/infra/cli/generated/infra.zsh-completions b/crates/infra/cli/generated/infra.zsh-completions index 7714b6f004..ef70959a9d 100644 --- a/crates/infra/cli/generated/infra.zsh-completions +++ b/crates/infra/cli/generated/infra.zsh-completions @@ -79,8 +79,8 @@ _arguments "${_arguments_options[@]}" \ _arguments "${_arguments_options[@]}" \ '-h[Print help (see more with '\''--help'\'')]' \ '--help[Print help (see more with '\''--help'\'')]' \ -':command:((slang_solidity\:"Run the public '\''slang_solidity'\'' crate shipped to Cargo users" -solidity_testing_smoke\:"Run smoke tests of the Solidity parser against source files from the Sanctuary repositories"))' \ +':command:((slang_solidity\:"Runs the public '\''slang_solidity'\'' crate shipped to Cargo users" +solidity_testing_sanctuary\:"Runs the Solidity parser against source files from the Sanctuary repositories"))' \ '*::args:' \ && ret=0 ;; diff --git a/crates/infra/cli/src/commands/run/mod.rs b/crates/infra/cli/src/commands/run/mod.rs index f8c07dacce..124d4091eb 100644 --- a/crates/infra/cli/src/commands/run/mod.rs +++ b/crates/infra/cli/src/commands/run/mod.rs @@ -19,26 +19,42 @@ enum RunCommand { * User-facing: * */ - /// Run the public 'slang_solidity' crate shipped to Cargo users. + /// Runs the public 'slang_solidity' crate shipped to Cargo users. #[clap(name = "slang_solidity")] SlangSolidity, - - /// Run smoke tests of the Solidity parser against source files from the Sanctuary repositories. - #[clap(name = "solidity_testing_smoke")] - SolidityTestingSmoke, + /// Runs the Solidity parser against source files from the Sanctuary repositories. + #[clap(name = "solidity_testing_sanctuary")] + SolidityTestingSanctuary, /* * * Hidden (for automation only): * */ + /// Runs codegen for the Rust parser crate. #[clap(name = "solidity_cargo_build", hide = true)] SolidityCargoBuild, - + /// Runs codegen for the NAPI-exposed parser crate. #[clap(name = "solidity_npm_build", hide = true)] SolidityNpmBuild, } +impl RunCommand { + fn should_run_in_release_mode(&self) -> bool { + match self { + Self::SolidityTestingSanctuary => { + // This crate parses tens of thousands of Solidity files: + // It is worth spending the extra time to recompiling its dependencies. + return true; + } + Self::SlangSolidity | Self::SolidityCargoBuild | Self::SolidityNpmBuild => { + // These run during local development. Just build in debug mode. + return false; + } + }; + } +} + impl RunController { pub fn execute(&self) -> Result<()> { let crate_name = self.command.clap_name(); @@ -48,7 +64,7 @@ impl RunController { let mut command = Command::new("cargo").arg("run"); - if self.command == RunCommand::SolidityTestingSmoke { + if self.command.should_run_in_release_mode() { command = command.flag("--release"); } diff --git a/crates/solidity/testing/sanctuary/.cargo/config.toml b/crates/solidity/testing/sanctuary/.cargo/config.toml new file mode 100644 index 0000000000..5261254ae8 --- /dev/null +++ b/crates/solidity/testing/sanctuary/.cargo/config.toml @@ -0,0 +1,4 @@ +[build] +# This crate builds and runs in release mode. +# Let's use a separate target-dir "$THIS_CRATE/target" to avoid invalidating the workspace-level cache. +target-dir = "./target" diff --git a/crates/solidity/testing/smoke/Cargo.toml b/crates/solidity/testing/sanctuary/Cargo.toml similarity index 92% rename from crates/solidity/testing/smoke/Cargo.toml rename to crates/solidity/testing/sanctuary/Cargo.toml index 95e954f935..8dbbed26c6 100644 --- a/crates/solidity/testing/smoke/Cargo.toml +++ b/crates/solidity/testing/sanctuary/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "solidity_testing_smoke" +name = "solidity_testing_sanctuary" version.workspace = true rust-version.workspace = true edition.workspace = true diff --git a/crates/solidity/testing/smoke/src/datasets/git.rs b/crates/solidity/testing/sanctuary/src/datasets/git.rs similarity index 98% rename from crates/solidity/testing/smoke/src/datasets/git.rs rename to crates/solidity/testing/sanctuary/src/datasets/git.rs index 8edd41a0a6..b1bbf34831 100644 --- a/crates/solidity/testing/smoke/src/datasets/git.rs +++ b/crates/solidity/testing/sanctuary/src/datasets/git.rs @@ -24,7 +24,7 @@ impl Dataset for GitDataset { } fn prepare(&self) -> Result> { - let dataset_dir = CargoWorkspace::locate_source_crate("solidity_testing_smoke")? + let dataset_dir = CargoWorkspace::locate_source_crate("solidity_testing_sanctuary")? .join("target/git-datasets") .join(self.name); diff --git a/crates/solidity/testing/smoke/src/datasets/mod.rs b/crates/solidity/testing/sanctuary/src/datasets/mod.rs similarity index 100% rename from crates/solidity/testing/smoke/src/datasets/mod.rs rename to crates/solidity/testing/sanctuary/src/datasets/mod.rs diff --git a/crates/solidity/testing/smoke/src/main.rs b/crates/solidity/testing/sanctuary/src/main.rs similarity index 100% rename from crates/solidity/testing/smoke/src/main.rs rename to crates/solidity/testing/sanctuary/src/main.rs diff --git a/crates/solidity/testing/smoke/src/reporting.rs b/crates/solidity/testing/sanctuary/src/reporting.rs similarity index 100% rename from crates/solidity/testing/smoke/src/reporting.rs rename to crates/solidity/testing/sanctuary/src/reporting.rs