mirror of
https://github.com/ipetkov/crane.git
synced 2024-11-22 23:17:15 +03:00
Add tests for mkDummySrc
* Also fix a bug with copying over .cargo/config files
This commit is contained in:
parent
daae0bac2b
commit
791f1b2241
@ -66,6 +66,8 @@ onlyDrvs (lib.makeScope myLib.newScope (self:
|
||||
touch $out
|
||||
'';
|
||||
|
||||
mkDummySrcTests = callPackage ./mkDummySrcTests { };
|
||||
|
||||
simple = myLib.buildPackage {
|
||||
src = ./simple;
|
||||
};
|
||||
|
21
checks/mkDummySrcTests/default.nix
Normal file
21
checks/mkDummySrcTests/default.nix
Normal file
@ -0,0 +1,21 @@
|
||||
{ linkFarmFromDrvs
|
||||
, mkDummySrc
|
||||
, runCommand
|
||||
}:
|
||||
|
||||
let
|
||||
cmpDummySrc = name: path:
|
||||
let
|
||||
dummySrc = mkDummySrc {
|
||||
src = path + /input;
|
||||
};
|
||||
in
|
||||
runCommand "compare-${name}" { } ''
|
||||
diff -r ${path + /expected} ${dummySrc}
|
||||
touch $out
|
||||
'';
|
||||
in
|
||||
linkFarmFromDrvs "cleanCargoToml" [
|
||||
(cmpDummySrc "single" ./single)
|
||||
(cmpDummySrc "single-alt" ./single-alt)
|
||||
]
|
2
checks/mkDummySrcTests/single-alt/expected/.cargo/config
Normal file
2
checks/mkDummySrcTests/single-alt/expected/.cargo/config
Normal file
@ -0,0 +1,2 @@
|
||||
[alias]
|
||||
b = "build"
|
7
checks/mkDummySrcTests/single-alt/expected/Cargo.lock
generated
Normal file
7
checks/mkDummySrcTests/single-alt/expected/Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "mkDummySrcSimple"
|
||||
version = "0.1.0"
|
8
checks/mkDummySrcTests/single-alt/expected/Cargo.toml
Normal file
8
checks/mkDummySrcTests/single-alt/expected/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[lib]
|
||||
name = "foo"
|
||||
path = "src/custom.rs"
|
||||
|
||||
[package]
|
||||
edition = "2021"
|
||||
name = "mkDummySrcSimple"
|
||||
version = "0.1.0"
|
2
checks/mkDummySrcTests/single-alt/expected/build.rs
Normal file
2
checks/mkDummySrcTests/single-alt/expected/build.rs
Normal file
@ -0,0 +1,2 @@
|
||||
#![allow(dead_code)]
|
||||
pub fn main() {}
|
2
checks/mkDummySrcTests/single-alt/expected/src/custom.rs
Normal file
2
checks/mkDummySrcTests/single-alt/expected/src/custom.rs
Normal file
@ -0,0 +1,2 @@
|
||||
#![allow(dead_code)]
|
||||
pub fn main() {}
|
2
checks/mkDummySrcTests/single-alt/expected/src/main.rs
Normal file
2
checks/mkDummySrcTests/single-alt/expected/src/main.rs
Normal file
@ -0,0 +1,2 @@
|
||||
#![allow(dead_code)]
|
||||
pub fn main() {}
|
2
checks/mkDummySrcTests/single-alt/input/.cargo/config
Normal file
2
checks/mkDummySrcTests/single-alt/input/.cargo/config
Normal file
@ -0,0 +1,2 @@
|
||||
[alias]
|
||||
b = "build"
|
@ -0,0 +1,2 @@
|
||||
[alias]
|
||||
b = "build"
|
7
checks/mkDummySrcTests/single-alt/input/Cargo.lock
generated
Normal file
7
checks/mkDummySrcTests/single-alt/input/Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "mkDummySrcSimple"
|
||||
version = "0.1.0"
|
8
checks/mkDummySrcTests/single-alt/input/Cargo.toml
Normal file
8
checks/mkDummySrcTests/single-alt/input/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "mkDummySrcSimple"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
name = "foo"
|
||||
path = "src/custom.rs"
|
4
checks/mkDummySrcTests/single-alt/input/src/custom.rs
Normal file
4
checks/mkDummySrcTests/single-alt/input/src/custom.rs
Normal file
@ -0,0 +1,4 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
|
2
checks/mkDummySrcTests/single/expected/.cargo/config
Normal file
2
checks/mkDummySrcTests/single/expected/.cargo/config
Normal file
@ -0,0 +1,2 @@
|
||||
[alias]
|
||||
b = "build"
|
7
checks/mkDummySrcTests/single/expected/Cargo.lock
generated
Normal file
7
checks/mkDummySrcTests/single/expected/Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "mkDummySrcSimple"
|
||||
version = "0.1.0"
|
35
checks/mkDummySrcTests/single/expected/Cargo.toml
Normal file
35
checks/mkDummySrcTests/single/expected/Cargo.toml
Normal file
@ -0,0 +1,35 @@
|
||||
[lib]
|
||||
name = "foo"
|
||||
|
||||
[package]
|
||||
edition = "2021"
|
||||
name = "mkDummySrcSimple"
|
||||
version = "0.1.0"
|
||||
|
||||
[[bench]]
|
||||
name = "bench1"
|
||||
|
||||
[[bench]]
|
||||
name = "bench2"
|
||||
path = "benches/custom.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "bin1"
|
||||
|
||||
[[bin]]
|
||||
name = "bin2"
|
||||
path = "src/bin/custom.rs"
|
||||
|
||||
[[example]]
|
||||
name = "example1"
|
||||
|
||||
[[example]]
|
||||
name = "example2"
|
||||
path = "examples/custom.rs"
|
||||
|
||||
[[test]]
|
||||
name = "test1"
|
||||
|
||||
[[test]]
|
||||
name = "test2"
|
||||
path = "tests/custom.rs"
|
2
checks/mkDummySrcTests/single/expected/benches/bench1.rs
Normal file
2
checks/mkDummySrcTests/single/expected/benches/bench1.rs
Normal file
@ -0,0 +1,2 @@
|
||||
#![allow(dead_code)]
|
||||
pub fn main() {}
|
2
checks/mkDummySrcTests/single/expected/benches/custom.rs
Normal file
2
checks/mkDummySrcTests/single/expected/benches/custom.rs
Normal file
@ -0,0 +1,2 @@
|
||||
#![allow(dead_code)]
|
||||
pub fn main() {}
|
2
checks/mkDummySrcTests/single/expected/build.rs
Normal file
2
checks/mkDummySrcTests/single/expected/build.rs
Normal file
@ -0,0 +1,2 @@
|
||||
#![allow(dead_code)]
|
||||
pub fn main() {}
|
@ -0,0 +1,2 @@
|
||||
#![allow(dead_code)]
|
||||
pub fn main() {}
|
@ -0,0 +1,2 @@
|
||||
#![allow(dead_code)]
|
||||
pub fn main() {}
|
2
checks/mkDummySrcTests/single/expected/src/bin/bin1.rs
Normal file
2
checks/mkDummySrcTests/single/expected/src/bin/bin1.rs
Normal file
@ -0,0 +1,2 @@
|
||||
#![allow(dead_code)]
|
||||
pub fn main() {}
|
2
checks/mkDummySrcTests/single/expected/src/bin/custom.rs
Normal file
2
checks/mkDummySrcTests/single/expected/src/bin/custom.rs
Normal file
@ -0,0 +1,2 @@
|
||||
#![allow(dead_code)]
|
||||
pub fn main() {}
|
2
checks/mkDummySrcTests/single/expected/src/lib.rs
Normal file
2
checks/mkDummySrcTests/single/expected/src/lib.rs
Normal file
@ -0,0 +1,2 @@
|
||||
#![allow(dead_code)]
|
||||
pub fn main() {}
|
2
checks/mkDummySrcTests/single/expected/src/main.rs
Normal file
2
checks/mkDummySrcTests/single/expected/src/main.rs
Normal file
@ -0,0 +1,2 @@
|
||||
#![allow(dead_code)]
|
||||
pub fn main() {}
|
2
checks/mkDummySrcTests/single/expected/tests/custom.rs
Normal file
2
checks/mkDummySrcTests/single/expected/tests/custom.rs
Normal file
@ -0,0 +1,2 @@
|
||||
#![allow(dead_code)]
|
||||
pub fn main() {}
|
2
checks/mkDummySrcTests/single/expected/tests/test1.rs
Normal file
2
checks/mkDummySrcTests/single/expected/tests/test1.rs
Normal file
@ -0,0 +1,2 @@
|
||||
#![allow(dead_code)]
|
||||
pub fn main() {}
|
2
checks/mkDummySrcTests/single/input/.cargo/config
Normal file
2
checks/mkDummySrcTests/single/input/.cargo/config
Normal file
@ -0,0 +1,2 @@
|
||||
[alias]
|
||||
b = "build"
|
7
checks/mkDummySrcTests/single/input/Cargo.lock
generated
Normal file
7
checks/mkDummySrcTests/single/input/Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "mkDummySrcSimple"
|
||||
version = "0.1.0"
|
35
checks/mkDummySrcTests/single/input/Cargo.toml
Normal file
35
checks/mkDummySrcTests/single/input/Cargo.toml
Normal file
@ -0,0 +1,35 @@
|
||||
[package]
|
||||
name = "mkDummySrcSimple"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
name = "foo"
|
||||
|
||||
[[bin]]
|
||||
name = "bin1"
|
||||
|
||||
[[bin]]
|
||||
name = "bin2"
|
||||
path = "src/bin/custom.rs"
|
||||
|
||||
[[example]]
|
||||
name = "example1"
|
||||
|
||||
[[example]]
|
||||
name = "example2"
|
||||
path = "examples/custom.rs"
|
||||
|
||||
[[test]]
|
||||
name = "test1"
|
||||
|
||||
[[test]]
|
||||
name = "test2"
|
||||
path = "tests/custom.rs"
|
||||
|
||||
[[bench]]
|
||||
name = "bench1"
|
||||
|
||||
[[bench]]
|
||||
name = "bench2"
|
||||
path = "benches/custom.rs"
|
4
checks/mkDummySrcTests/single/input/benches/bench1.rs
Normal file
4
checks/mkDummySrcTests/single/input/benches/bench1.rs
Normal file
@ -0,0 +1,4 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
|
4
checks/mkDummySrcTests/single/input/benches/custom.rs
Normal file
4
checks/mkDummySrcTests/single/input/benches/custom.rs
Normal file
@ -0,0 +1,4 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
|
4
checks/mkDummySrcTests/single/input/examples/custom.rs
Normal file
4
checks/mkDummySrcTests/single/input/examples/custom.rs
Normal file
@ -0,0 +1,4 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
|
4
checks/mkDummySrcTests/single/input/examples/example1.rs
Normal file
4
checks/mkDummySrcTests/single/input/examples/example1.rs
Normal file
@ -0,0 +1,4 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
|
4
checks/mkDummySrcTests/single/input/src/bin/bin1.rs
Normal file
4
checks/mkDummySrcTests/single/input/src/bin/bin1.rs
Normal file
@ -0,0 +1,4 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
|
4
checks/mkDummySrcTests/single/input/src/bin/custom.rs
Normal file
4
checks/mkDummySrcTests/single/input/src/bin/custom.rs
Normal file
@ -0,0 +1,4 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
|
4
checks/mkDummySrcTests/single/input/src/lib.rs
Normal file
4
checks/mkDummySrcTests/single/input/src/lib.rs
Normal file
@ -0,0 +1,4 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
|
4
checks/mkDummySrcTests/single/input/tests/custom.rs
Normal file
4
checks/mkDummySrcTests/single/input/tests/custom.rs
Normal file
@ -0,0 +1,4 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
|
4
checks/mkDummySrcTests/single/input/tests/test1.rs
Normal file
4
checks/mkDummySrcTests/single/input/tests/test1.rs
Normal file
@ -0,0 +1,4 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
|
@ -35,9 +35,9 @@ let
|
||||
# the .toml extension is preferred, but the extension-less path takes precedence
|
||||
# https://doc.rust-lang.org/cargo/reference/config.html
|
||||
if pathExists cargoConfig
|
||||
then "cp ${cargoConfig} $out/.cargo"
|
||||
then "cp ${cargoConfig} $out/.cargo/config"
|
||||
else if pathExists cargoConfigToml
|
||||
then "cp ${cargoConfigToml} $out/.cargo"
|
||||
then "cp ${cargoConfigToml} $out/.cargo/config.toml"
|
||||
else "";
|
||||
|
||||
cpDummy = path: ''
|
||||
|
Loading…
Reference in New Issue
Block a user