1use std::process::Command;
4
5pub mod adoption;
6mod artifact_io;
7mod bootstrap_store;
8mod build_profile;
9pub mod build_provenance;
10pub mod canister_build;
11mod cargo_metadata;
12pub mod deployment_catalog;
13pub mod deployment_truth;
14pub mod evidence_envelope;
15pub mod format;
16pub mod icp;
17pub mod icp_config;
18pub mod install_root;
19pub mod installed_deployment;
20pub mod policy_gate;
21pub mod registry;
22pub mod release_set;
23pub mod replica_query;
24pub mod response_parse;
25pub mod subnet_catalog;
26pub mod table;
27#[cfg(test)]
28mod test_support;
29mod workspace_discovery;
30
31pub(crate) fn cargo_command() -> Command {
32 let cargo = std::env::var_os("CARGO").unwrap_or_else(|| "cargo".into());
33 let mut command = Command::new(cargo);
34
35 if let Some(toolchain) = std::env::var_os("RUSTUP_TOOLCHAIN") {
36 command.env("RUSTUP_TOOLCHAIN", toolchain);
37 }
38
39 command
40}
41
42pub(crate) fn icp_environment_from_env() -> String {
43 std::env::var("ICP_ENVIRONMENT").unwrap_or_else(|_| "local".to_string())
44}
45
46pub(crate) fn should_export_candid_artifacts(environment: &str) -> bool {
47 environment == "local"
48}
49
50pub(crate) fn remove_optional_file(path: &std::path::Path) -> std::io::Result<()> {
51 match std::fs::remove_file(path) {
52 Ok(()) => Ok(()),
53 Err(err) if err.kind() == std::io::ErrorKind::NotFound => Ok(()),
54 Err(err) => Err(err),
55 }
56}
57
58#[cfg(test)]
59mod tests {
60 use super::should_export_candid_artifacts;
61
62 #[test]
64 fn candid_artifact_export_is_dev_only() {
65 assert!(should_export_candid_artifacts("local"));
66 assert!(!should_export_candid_artifacts("ic"));
67 }
68}