summaryrefslogtreecommitdiffstats
path: root/src/tools/cargo/tests/testsuite/cargo_targets.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:41:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:41:41 +0000
commit10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87 (patch)
treebdffd5d80c26cf4a7a518281a204be1ace85b4c1 /src/tools/cargo/tests/testsuite/cargo_targets.rs
parentReleasing progress-linux version 1.70.0+dfsg1-9~progress7.99u1. (diff)
downloadrustc-10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87.tar.xz
rustc-10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87.zip
Merging upstream version 1.70.0+dfsg2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/cargo/tests/testsuite/cargo_targets.rs')
-rw-r--r--src/tools/cargo/tests/testsuite/cargo_targets.rs68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/tools/cargo/tests/testsuite/cargo_targets.rs b/src/tools/cargo/tests/testsuite/cargo_targets.rs
new file mode 100644
index 000000000..fcf293019
--- /dev/null
+++ b/src/tools/cargo/tests/testsuite/cargo_targets.rs
@@ -0,0 +1,68 @@
+//! Tests specifically related to target handling (lib, bins, examples, tests, benches).
+
+use cargo_test_support::project;
+
+#[cargo_test]
+fn warn_unmatched_target_filters() {
+ let p = project()
+ .file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "foo"
+ version = "0.1.0"
+
+ [lib]
+ test = false
+ bench = false
+ "#,
+ )
+ .file("src/lib.rs", r#"fn main() {}"#)
+ .build();
+
+ p.cargo("check --tests --bins --examples --benches")
+ .with_stderr(
+ "\
+[WARNING] Target filters `bins`, `tests`, `examples`, `benches` specified, \
+but no targets matched. This is a no-op
+[FINISHED][..]
+",
+ )
+ .run();
+}
+
+#[cargo_test]
+fn reserved_windows_target_name() {
+ let p = project()
+ .file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "foo"
+ version = "0.1.0"
+
+ [[bin]]
+ name = "con"
+ path = "src/main.rs"
+ "#,
+ )
+ .file("src/main.rs", "fn main() {}")
+ .build();
+
+ if cfg!(windows) {
+ p.cargo("check")
+ .with_stderr(
+ "\
+[WARNING] binary target `con` is a reserved Windows filename, \
+this target will not work on Windows platforms
+[CHECKING] foo[..]
+[FINISHED][..]
+",
+ )
+ .run();
+ } else {
+ p.cargo("check")
+ .with_stderr("[CHECKING] foo[..]\n[FINISHED][..]")
+ .run();
+ }
+}