diff --git a/checks/default.nix b/checks/default.nix index d752cc0..7d22a5a 100644 --- a/checks/default.nix +++ b/checks/default.nix @@ -47,6 +47,12 @@ onlyDrvs (lib.makeScope myLib.newScope (self: features = callPackage ./features { }; + illegalBin = myLib.buildPackage { + pname = "illegalBin"; + version = "0.0.1"; + src = ./illegal-bin; + }; + manyLibs = myLib.buildPackage { src = ./with-libs; pname = "my-libs"; @@ -72,6 +78,11 @@ onlyDrvs (lib.makeScope myLib.newScope (self: src = ./simple; }; + # Test building a real world example + ripgrep = myLib.buildPackage { + inherit (pkgs.ripgrep) pname src version; + }; + smoke = callPackage ./smoke.nix { }; smokeSimple = self.smoke [ "simple" ] self.simple; diff --git a/checks/illegal-bin/Cargo.lock b/checks/illegal-bin/Cargo.lock new file mode 100644 index 0000000..641ff1c --- /dev/null +++ b/checks/illegal-bin/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "examples" +version = "0.0.0" diff --git a/checks/illegal-bin/Cargo.toml b/checks/illegal-bin/Cargo.toml new file mode 100644 index 0000000..852d935 --- /dev/null +++ b/checks/illegal-bin/Cargo.toml @@ -0,0 +1,15 @@ +# This cargo workspace contains a member called "examples" +# If we drop a dummy file in `src/main.rs` cargo will complain with: +# +# error: failed to load manifest for workspace member `/build/dummy-src/examples` +# Caused by: +# failed to parse manifest at `/build/dummy-src/examples/Cargo.toml` +# Caused by: +# the binary target name `examples` is forbidden, it conflicts with with cargo's build directory names +# +# Instead we need to drop a dummy file at `src/lib.rs`, and this is a +# regression test for that case. +[workspace] +members = [ + "examples", +] diff --git a/checks/illegal-bin/examples/Cargo.toml b/checks/illegal-bin/examples/Cargo.toml new file mode 100644 index 0000000..990e0d2 --- /dev/null +++ b/checks/illegal-bin/examples/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "examples" +version = "0.0.0" +publish = false +edition = "2021" + +[[example]] +name = "foo" +path = "foo.rs" diff --git a/checks/illegal-bin/examples/foo.rs b/checks/illegal-bin/examples/foo.rs new file mode 100644 index 0000000..f79c691 --- /dev/null +++ b/checks/illegal-bin/examples/foo.rs @@ -0,0 +1,2 @@ +fn main() { +} diff --git a/checks/mkDummySrcTests/single-alt/expected/src/main.rs b/checks/mkDummySrcTests/single-alt/expected/src/lib.rs similarity index 100% rename from checks/mkDummySrcTests/single-alt/expected/src/main.rs rename to checks/mkDummySrcTests/single-alt/expected/src/lib.rs diff --git a/checks/mkDummySrcTests/single/expected/src/main.rs b/checks/mkDummySrcTests/single/expected/src/main.rs deleted file mode 100644 index 7edb46d..0000000 --- a/checks/mkDummySrcTests/single/expected/src/main.rs +++ /dev/null @@ -1,2 +0,0 @@ -#![allow(dead_code)] -pub fn main() {} diff --git a/checks/mkDummySrcTests/workspace/expected/member/foo/bar/baz/src/main.rs b/checks/mkDummySrcTests/workspace/expected/member/foo/bar/baz/src/main.rs deleted file mode 100644 index 7edb46d..0000000 --- a/checks/mkDummySrcTests/workspace/expected/member/foo/bar/baz/src/main.rs +++ /dev/null @@ -1,2 +0,0 @@ -#![allow(dead_code)] -pub fn main() {} diff --git a/checks/mkDummySrcTests/workspace/expected/member/qux/src/main.rs b/checks/mkDummySrcTests/workspace/expected/member/qux/src/main.rs deleted file mode 100644 index 7edb46d..0000000 --- a/checks/mkDummySrcTests/workspace/expected/member/qux/src/main.rs +++ /dev/null @@ -1,2 +0,0 @@ -#![allow(dead_code)] -pub fn main() {} diff --git a/lib/mkDummySrc.nix b/lib/mkDummySrc.nix index deda60e..42e1cb0 100644 --- a/lib/mkDummySrc.nix +++ b/lib/mkDummySrc.nix @@ -96,7 +96,7 @@ let # To build build-dependencies ${cpDummy parentDir "build.rs"} # To build regular and dev dependencies (cargo build + cargo test) - ${cpDummy parentDir "src/main.rs"} + ${cpDummy parentDir "src/lib.rs"} # Stub all other targets in case they have particular feature combinations ${safeStubLib}