Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion crate2nix/Cargo.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3284,7 +3284,10 @@ rec {
let
drv = testCrate.override (_: {
buildTests = true;
});
} // (lib.optionalAttrs (testCrate ? testedCrate) {
# if nixpkgs is recent enough to support testedCrate, provide it
testedCrate = testCrate;
}));
# If the user hasn't set any pre/post commands, we don't want to
# insert empty lines. This means that any existing users of crate2nix
# don't get a spurious rebuild unless they set these explicitly.
Expand Down
5 changes: 4 additions & 1 deletion crate2nix/templates/nix/crate2nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ rec {
let
drv = testCrate.override (_: {
buildTests = true;
});
} // (lib.optionalAttrs (testCrate ? testedCrate) {
# if nixpkgs is recent enough to support testedCrate, provide it
testedCrate = testCrate;
}));
# If the user hasn't set any pre/post commands, we don't want to
# insert empty lines. This means that any existing users of crate2nix
# don't get a spurious rebuild unless they set these explicitly.
Expand Down
5 changes: 4 additions & 1 deletion sample_projects/bin_with_git_submodule_dep/Cargo.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,10 @@ rec {
let
drv = testCrate.override (_: {
buildTests = true;
});
} // (lib.optionalAttrs (testCrate ? testedCrate) {
# if nixpkgs is recent enough to support testedCrate, provide it
testedCrate = testCrate;
}));
# If the user hasn't set any pre/post commands, we don't want to
# insert empty lines. This means that any existing users of crate2nix
# don't get a spurious rebuild unless they set these explicitly.
Expand Down
5 changes: 4 additions & 1 deletion sample_projects/codegen/Cargo.nix
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,10 @@ rec {
let
drv = testCrate.override (_: {
buildTests = true;
});
} // (lib.optionalAttrs (testCrate ? testedCrate) {
# if nixpkgs is recent enough to support testedCrate, provide it
testedCrate = testCrate;
}));
# If the user hasn't set any pre/post commands, we don't want to
# insert empty lines. This means that any existing users of crate2nix
# don't get a spurious rebuild unless they set these explicitly.
Expand Down
1 change: 0 additions & 1 deletion sample_projects/future_util_multi_version/result

This file was deleted.

7 changes: 7 additions & 0 deletions sample_projects/integration_test_with_envvar/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions sample_projects/integration_test_with_envvar/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
name = "integration_test_with_envvar"
version = "0.1.0"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("exe-with-dash.rs");
}
3 changes: 3 additions & 0 deletions sample_projects/integration_test_with_envvar/src/bin/exe.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("exe.rs");
}
3 changes: 3 additions & 0 deletions sample_projects/integration_test_with_envvar/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("main.rs");
}
9 changes: 9 additions & 0 deletions sample_projects/integration_test_with_envvar/test.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{ pkgs ? import ../../nix/nixpkgs.nix { config = { }; }
, generatedCargoNix ? ./Cargo.nix { }
}:
let
instantiatedBuild = pkgs.callPackage generatedCargoNix { };
in
instantiatedBuild.rootCrate.build.override {
runTests = true;
}
15 changes: 15 additions & 0 deletions sample_projects/integration_test_with_envvar/tests/foo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#[test]
fn test_main() {
let mut cmd = std::process::Command::new(env!("CARGO_BIN_EXE_integration_test_with_envvar"));
assert_eq!(&cmd.output().unwrap().stdout, b"main.rs\n");
}
#[test]
fn test_exe() {
let mut cmd = std::process::Command::new(env!("CARGO_BIN_EXE_exe"));
assert_eq!(&cmd.output().unwrap().stdout, b"exe.rs\n");
}
#[test]
fn test_exe2() {
let mut cmd = std::process::Command::new(env!("CARGO_BIN_EXE_exe-with-dash"));
assert_eq!(&cmd.output().unwrap().stdout, b"exe-with-dash.rs\n");
}
1 change: 0 additions & 1 deletion sample_projects/renamed_build_deps/result

This file was deleted.

5 changes: 4 additions & 1 deletion sample_projects/sub_dir_crates/Cargo.nix
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,10 @@ rec {
let
drv = testCrate.override (_: {
buildTests = true;
});
} // (lib.optionalAttrs (testCrate ? testedCrate) {
# if nixpkgs is recent enough to support testedCrate, provide it
testedCrate = testCrate;
}));
# If the user hasn't set any pre/post commands, we don't want to
# insert empty lines. This means that any existing users of crate2nix
# don't get a spurious rebuild unless they set these explicitly.
Expand Down
16 changes: 12 additions & 4 deletions sample_projects/with_problematic_crates/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,20 @@ let
];
}

{
name = "integration_test_with_envvar";
src = ./sample_projects/integration_test_with_envvar;
cargoToml = "Cargo.toml";
customBuild = "sample_projects/integration_test_with_envvar/test.nix";
expectedOutput = "main.rs";
expectedTestOutputs = [
"test test_exe ... ok"
"test test_exe2 ... ok"
"test test_main ... ok"

];
}

{
name = "cross_compile_build_dependencies";
src = ./sample_projects/cross_compile_build_dependencies;
Expand Down
Loading