Add tests for mkDummySrc

* Also fix a bug with copying over .cargo/config files
This commit is contained in:
Ivan Petkov 2022-01-05 20:46:05 -08:00
parent daae0bac2b
commit 791f1b2241
No known key found for this signature in database
GPG Key ID: BB6F9EFC065832B6
40 changed files with 217 additions and 2 deletions

View File

@ -66,6 +66,8 @@ onlyDrvs (lib.makeScope myLib.newScope (self:
touch $out
'';
mkDummySrcTests = callPackage ./mkDummySrcTests { };
simple = myLib.buildPackage {
src = ./simple;
};

View 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)
]

View File

@ -0,0 +1,2 @@
[alias]
b = "build"

View 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"

View File

@ -0,0 +1,8 @@
[lib]
name = "foo"
path = "src/custom.rs"
[package]
edition = "2021"
name = "mkDummySrcSimple"
version = "0.1.0"

View File

@ -0,0 +1,2 @@
#![allow(dead_code)]
pub fn main() {}

View File

@ -0,0 +1,2 @@
#![allow(dead_code)]
pub fn main() {}

View File

@ -0,0 +1,2 @@
#![allow(dead_code)]
pub fn main() {}

View File

@ -0,0 +1,2 @@
[alias]
b = "build"

View File

@ -0,0 +1,2 @@
[alias]
b = "build"

View 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"

View File

@ -0,0 +1,8 @@
[package]
name = "mkDummySrcSimple"
version = "0.1.0"
edition = "2021"
[lib]
name = "foo"
path = "src/custom.rs"

View File

@ -0,0 +1,4 @@
fn main() {
println!("Hello, world!");
}

View File

@ -0,0 +1,2 @@
[alias]
b = "build"

View 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"

View 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"

View File

@ -0,0 +1,2 @@
#![allow(dead_code)]
pub fn main() {}

View File

@ -0,0 +1,2 @@
#![allow(dead_code)]
pub fn main() {}

View File

@ -0,0 +1,2 @@
#![allow(dead_code)]
pub fn main() {}

View File

@ -0,0 +1,2 @@
#![allow(dead_code)]
pub fn main() {}

View File

@ -0,0 +1,2 @@
#![allow(dead_code)]
pub fn main() {}

View File

@ -0,0 +1,2 @@
#![allow(dead_code)]
pub fn main() {}

View File

@ -0,0 +1,2 @@
#![allow(dead_code)]
pub fn main() {}

View File

@ -0,0 +1,2 @@
#![allow(dead_code)]
pub fn main() {}

View File

@ -0,0 +1,2 @@
#![allow(dead_code)]
pub fn main() {}

View File

@ -0,0 +1,2 @@
#![allow(dead_code)]
pub fn main() {}

View File

@ -0,0 +1,2 @@
#![allow(dead_code)]
pub fn main() {}

View File

@ -0,0 +1,2 @@
[alias]
b = "build"

View 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"

View 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"

View File

@ -0,0 +1,4 @@
fn main() {
println!("Hello, world!");
}

View File

@ -0,0 +1,4 @@
fn main() {
println!("Hello, world!");
}

View File

@ -0,0 +1,4 @@
fn main() {
println!("Hello, world!");
}

View File

@ -0,0 +1,4 @@
fn main() {
println!("Hello, world!");
}

View File

@ -0,0 +1,4 @@
fn main() {
println!("Hello, world!");
}

View File

@ -0,0 +1,4 @@
fn main() {
println!("Hello, world!");
}

View File

@ -0,0 +1,4 @@
fn main() {
println!("Hello, world!");
}

View File

@ -0,0 +1,4 @@
fn main() {
println!("Hello, world!");
}

View File

@ -0,0 +1,4 @@
fn main() {
println!("Hello, world!");
}

View File

@ -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: ''