Skip to content

Commit 801b223

Browse files
committed
test(cli): Show existing --target behavior
1 parent 0bd1f71 commit 801b223

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

tests/testsuite/list_availables.rs

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const BIN: u8 = 1 << 1;
88
const TEST: u8 = 1 << 2;
99
const BENCH: u8 = 1 << 3;
1010
const PACKAGE: u8 = 1 << 4;
11+
const TARGET: u8 = 1 << 5;
1112

1213
fn list_availables_test(command: &str, targets: u8) {
1314
let full_project = project()
@@ -159,56 +160,70 @@ No tests available.
159160
.with_status(101)
160161
.run();
161162
}
163+
164+
if targets & TARGET != 0 {
165+
empty_project
166+
.cargo(&format!("{} --target", command))
167+
.with_stderr(
168+
"\
169+
error: a value is required for '--target <TRIPLE>' but none was supplied
170+
171+
For more information, try '--help'.
172+
",
173+
)
174+
.with_status(1)
175+
.run();
176+
}
162177
}
163178

164179
#[cargo_test]
165180
fn build_list_availables() {
166-
list_availables_test("build", EXAMPLE | BIN | TEST | BENCH | PACKAGE);
181+
list_availables_test("build", EXAMPLE | BIN | TEST | BENCH | PACKAGE | TARGET);
167182
}
168183

169184
#[cargo_test]
170185
fn check_list_availables() {
171-
list_availables_test("check", EXAMPLE | BIN | TEST | BENCH | PACKAGE);
186+
list_availables_test("check", EXAMPLE | BIN | TEST | BENCH | PACKAGE | TARGET);
172187
}
173188

174189
#[cargo_test]
175190
fn doc_list_availables() {
176-
list_availables_test("doc", BIN | PACKAGE);
191+
list_availables_test("doc", BIN | PACKAGE | TARGET);
177192
}
178193

179194
#[cargo_test]
180195
fn fix_list_availables() {
181-
list_availables_test("fix", EXAMPLE | BIN | TEST | BENCH | PACKAGE);
196+
list_availables_test("fix", EXAMPLE | BIN | TEST | BENCH | PACKAGE | TARGET);
182197
}
183198

184199
#[cargo_test]
185200
fn run_list_availables() {
186-
list_availables_test("run", EXAMPLE | BIN | PACKAGE);
201+
list_availables_test("run", EXAMPLE | BIN | PACKAGE | TARGET);
187202
}
188203

189204
#[cargo_test]
190205
fn test_list_availables() {
191-
list_availables_test("test", EXAMPLE | BIN | TEST | BENCH | PACKAGE);
206+
list_availables_test("test", EXAMPLE | BIN | TEST | BENCH | PACKAGE | TARGET);
192207
}
193208

194209
#[cargo_test]
195210
fn bench_list_availables() {
196-
list_availables_test("bench", EXAMPLE | BIN | TEST | BENCH | PACKAGE);
211+
list_availables_test("bench", EXAMPLE | BIN | TEST | BENCH | PACKAGE | TARGET);
197212
}
198213

199214
#[cargo_test]
200215
fn install_list_availables() {
201-
list_availables_test("install", EXAMPLE | BIN);
216+
list_availables_test("install", EXAMPLE | BIN | TARGET);
202217
}
203218

204219
#[cargo_test]
205220
fn rustdoc_list_availables() {
206-
list_availables_test("rustdoc", EXAMPLE | BIN | TEST | BENCH | PACKAGE);
221+
list_availables_test("rustdoc", EXAMPLE | BIN | TEST | BENCH | PACKAGE | TARGET);
207222
}
208223

209224
#[cargo_test]
210225
fn rustc_list_availables() {
211-
list_availables_test("rustc", EXAMPLE | BIN | TEST | BENCH | PACKAGE);
226+
list_availables_test("rustc", EXAMPLE | BIN | TEST | BENCH | PACKAGE | TARGET);
212227
}
213228

214229
#[cargo_test]
@@ -218,12 +233,12 @@ fn pkgid_list_availables() {
218233

219234
#[cargo_test]
220235
fn tree_list_availables() {
221-
list_availables_test("tree", PACKAGE);
236+
list_availables_test("tree", PACKAGE | TARGET);
222237
}
223238

224239
#[cargo_test]
225240
fn clean_list_availables() {
226-
list_availables_test("clean", PACKAGE);
241+
list_availables_test("clean", PACKAGE | TARGET);
227242
}
228243

229244
#[cargo_test]

0 commit comments

Comments
 (0)