diff --git a/lib/mkDummySrc.nix b/lib/mkDummySrc.nix index bd2599b..569475f 100644 --- a/lib/mkDummySrc.nix +++ b/lib/mkDummySrc.nix @@ -53,7 +53,7 @@ let safeStubList = attr: defaultPath: let targetList = trimmedCargoToml.${attr} or [ ]; - paths = map (t: t.path or "${defaultPath}/${t.name}") targetList; + paths = map (t: t.path or "${defaultPath}/${t.name}.rs") targetList; commands = map cpDummy paths; in concatStringsSep "\n" commands; @@ -73,7 +73,7 @@ runCommand name { } '' # Stub all other targets in case they have particular feature combinations ${safeStubLib} ${safeStubList "bench" "benches"} - ${safeStubList "bin" "bin"} + ${safeStubList "bin" "src/bin"} ${safeStubList "example" "examples"} ${safeStubList "test" "tests"} '' diff --git a/tests/default.nix b/tests/default.nix index d028469..44476f7 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -41,6 +41,10 @@ pkgs.lib.makeScope myLib.newScope (self: touch $out ''; + depsOnlyVariousTargets = myLib.buildDepsOnly { + src = ./various-targets; + }; + simple = myLib.buildWithCargo { doCopyTargetToOutput = false; src = ./simple; diff --git a/tests/various-targets/Cargo.lock b/tests/various-targets/Cargo.lock new file mode 100644 index 0000000..dcd8682 --- /dev/null +++ b/tests/various-targets/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "various-targets" +version = "0.1.0" diff --git a/tests/various-targets/Cargo.toml b/tests/various-targets/Cargo.toml new file mode 100644 index 0000000..3c9aaf7 --- /dev/null +++ b/tests/various-targets/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "various-targets" +version = "0.1.0" +edition = "2021" + +[[bench]] +name = "foo" + +[[bench]] +name = "bar" + +[[bin]] +name = "baz" + +[[bin]] +name = "qux" + +[[example]] +name = "zuul" + +[[example]] +name = "corge" + +[[test]] +name = "grault" + +[[test]] +name = "garply" diff --git a/tests/various-targets/benches/bar.rs b/tests/various-targets/benches/bar.rs new file mode 100644 index 0000000..b81f72f --- /dev/null +++ b/tests/various-targets/benches/bar.rs @@ -0,0 +1,4 @@ +#[test] +fn foo() { +} + diff --git a/tests/various-targets/benches/foo.rs b/tests/various-targets/benches/foo.rs new file mode 100644 index 0000000..b81f72f --- /dev/null +++ b/tests/various-targets/benches/foo.rs @@ -0,0 +1,4 @@ +#[test] +fn foo() { +} + diff --git a/tests/various-targets/examples/corge.rs b/tests/various-targets/examples/corge.rs new file mode 100644 index 0000000..24e4cf8 --- /dev/null +++ b/tests/various-targets/examples/corge.rs @@ -0,0 +1,4 @@ +fn main() { + println!("Hello, world!"); +} + diff --git a/tests/various-targets/examples/zuul.rs b/tests/various-targets/examples/zuul.rs new file mode 100644 index 0000000..24e4cf8 --- /dev/null +++ b/tests/various-targets/examples/zuul.rs @@ -0,0 +1,4 @@ +fn main() { + println!("Hello, world!"); +} + diff --git a/tests/various-targets/src/bin/baz.rs b/tests/various-targets/src/bin/baz.rs new file mode 100644 index 0000000..f21c425 --- /dev/null +++ b/tests/various-targets/src/bin/baz.rs @@ -0,0 +1,2 @@ +pub fn main() { +} diff --git a/tests/various-targets/src/bin/qux.rs b/tests/various-targets/src/bin/qux.rs new file mode 100644 index 0000000..e5a3798 --- /dev/null +++ b/tests/various-targets/src/bin/qux.rs @@ -0,0 +1,3 @@ +pub fn main() { + println!("hello world"); +} diff --git a/tests/various-targets/tests/garply.rs b/tests/various-targets/tests/garply.rs new file mode 100644 index 0000000..e69de29 diff --git a/tests/various-targets/tests/grault.rs b/tests/various-targets/tests/grault.rs new file mode 100644 index 0000000..e69de29