Skip to content

Commit ea7817c

Browse files
authored
Updated the soldeer version to 0.2.18 and added extra CLI tests (#8441)
* Updated the soldeer version to 0.2.18 and added extra CLI tests * Forgot to push the root files * solving fmt * Updated git handling to match the rust way
1 parent dad3901 commit ea7817c

File tree

5 files changed

+102
-9
lines changed

5 files changed

+102
-9
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,6 @@ reqwest = { version = "0.12", default-features = false }
260260
tower = "0.4"
261261
tower-http = "0.5"
262262
# soldeer
263-
soldeer = "0.2.17"
263+
soldeer = "0.2.19"
264264

265265
proptest = "1"

crates/config/src/soldeer.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ pub struct MapDependency {
1313
/// The url from where the dependency was retrieved
1414
#[serde(default, skip_serializing_if = "Option::is_none")]
1515
pub url: Option<String>,
16+
17+
/// The commit in case git is used as dependency retrieval
18+
#[serde(default, skip_serializing_if = "Option::is_none")]
19+
pub rev: Option<String>,
1620
}
1721

1822
/// Type for Soldeer configs, under dependencies tag in the foundry.toml

crates/forge/bin/cmd/soldeer.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ use soldeer::commands::Subcommands;
66
// CLI arguments for `forge soldeer`.
77
#[derive(Clone, Debug, Parser)]
88
#[clap(override_usage = "forge soldeer install [DEPENDENCY]~[VERSION] <REMOTE_URL>
9+
forge soldeer install [DEPENDENCY]~[VERSION] <GIT_URL>
10+
forge soldeer install [DEPENDENCY]~[VERSION] <GIT_URL> --rev <REVISION>
11+
forge soldeer install [DEPENDENCY]~[VERSION] <GIT_URL> --rev <TAG>
912
forge soldeer push [DEPENDENCY]~[VERSION] <CUSTOM_PATH_OF_FILES>
1013
forge soldeer login
1114
forge soldeer update

crates/forge/tests/cli/soldeer.rs

Lines changed: 92 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,96 @@ libs = ["lib"]
4747
forge-std = "1.8.1"
4848
"#;
4949

50-
let actual_foundry_contents = read_file_to_string(&foundry_file);
51-
assert_eq!(foundry_contents, actual_foundry_contents);
50+
assert_data_eq!(read_file_to_string(&foundry_file), foundry_contents);
51+
});
52+
53+
forgesoldeer!(install_dependency_git, |prj, cmd| {
54+
let command = "install";
55+
let dependency = "forge-std~1.8.1";
56+
let git = "[email protected]:mario4582928/Mario.git";
57+
58+
let foundry_file = prj.root().join("foundry.toml");
59+
60+
cmd.arg("soldeer").args([command, dependency, git]);
61+
cmd.execute();
62+
63+
// Making sure the path was created to the dependency and that README.md exists
64+
// meaning that the dependencies were installed correctly
65+
let path_dep_forge = prj.root().join("dependencies").join("forge-std-1.8.1").join("README.md");
66+
assert!(path_dep_forge.exists());
67+
68+
// Making sure the lock contents are the right ones
69+
let path_lock_file = prj.root().join("soldeer.lock");
70+
let lock_contents = r#"
71+
[[dependencies]]
72+
name = "forge-std"
73+
version = "1.8.1"
74+
source = "[email protected]:mario4582928/Mario.git"
75+
checksum = "22868f426bd4dd0e682b5ec5f9bd55507664240c"
76+
"#;
77+
78+
let actual_lock_contents = read_file_to_string(&path_lock_file);
79+
assert_eq!(lock_contents, actual_lock_contents);
80+
81+
// Making sure the foundry contents are the right ones
82+
let foundry_contents = r#"[profile.default]
83+
src = "src"
84+
out = "out"
85+
libs = ["lib"]
86+
87+
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
88+
89+
[dependencies]
90+
forge-std = { version = "1.8.1", git = "[email protected]:mario4582928/Mario.git", rev = "22868f426bd4dd0e682b5ec5f9bd55507664240c" }
91+
"#;
92+
93+
assert_data_eq!(read_file_to_string(&foundry_file), foundry_contents);
94+
});
95+
96+
forgesoldeer!(install_dependency_git_commit, |prj, cmd| {
97+
let command = "install";
98+
let dependency = "forge-std~1.8.1";
99+
let git = "[email protected]:mario4582928/Mario.git";
100+
let rev_flag = "--rev";
101+
let commit = "7a0663eaf7488732f39550be655bad6694974cb3";
102+
103+
let foundry_file = prj.root().join("foundry.toml");
104+
105+
cmd.arg("soldeer").args([command, dependency, git, rev_flag, commit]);
106+
cmd.execute();
107+
108+
// Making sure the path was created to the dependency and that README.md exists
109+
// meaning that the dependencies were installed correctly
110+
let path_dep_forge =
111+
prj.root().join("dependencies").join("forge-std-1.8.1").join("JustATest2.md");
112+
assert!(path_dep_forge.exists());
113+
114+
// Making sure the lock contents are the right ones
115+
let path_lock_file = prj.root().join("soldeer.lock");
116+
let lock_contents = r#"
117+
[[dependencies]]
118+
name = "forge-std"
119+
version = "1.8.1"
120+
source = "[email protected]:mario4582928/Mario.git"
121+
checksum = "7a0663eaf7488732f39550be655bad6694974cb3"
122+
"#;
123+
124+
let actual_lock_contents = read_file_to_string(&path_lock_file);
125+
assert_eq!(lock_contents, actual_lock_contents);
126+
127+
// Making sure the foundry contents are the right ones
128+
let foundry_contents = r#"[profile.default]
129+
src = "src"
130+
out = "out"
131+
libs = ["lib"]
132+
133+
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
134+
135+
[dependencies]
136+
forge-std = { version = "1.8.1", git = "[email protected]:mario4582928/Mario.git", rev = "7a0663eaf7488732f39550be655bad6694974cb3" }
137+
"#;
138+
139+
assert_data_eq!(read_file_to_string(&foundry_file), foundry_contents);
52140
});
53141

54142
forgesoldeer!(update_dependencies, |prj, cmd| {
@@ -101,8 +189,7 @@ libs = ["lib"]
101189
forge-std = { version = "1.8.1" }
102190
"#;
103191

104-
let actual_foundry_contents = read_file_to_string(&foundry_file);
105-
assert_eq!(foundry_contents, actual_foundry_contents);
192+
assert_data_eq!(read_file_to_string(&foundry_file), foundry_contents);
106193
});
107194

108195
forgesoldeer!(update_dependencies_simple_version, |prj, cmd| {
@@ -156,8 +243,7 @@ libs = ["lib"]
156243
forge-std = "1.8.1"
157244
"#;
158245

159-
let actual_foundry_contents = read_file_to_string(&foundry_file);
160-
assert_eq!(foundry_contents, actual_foundry_contents);
246+
assert_data_eq!(read_file_to_string(&foundry_file), foundry_contents);
161247
});
162248

163249
forgesoldeer!(login, |prj, cmd| {

0 commit comments

Comments
 (0)