Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix support for .cargo/config #306

Merged
merged 1 commit into from
Aug 18, 2023
Merged
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
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let
libb.findGitDependencies { inherit (config) cargolock gitAllRefs gitSubmodules; };
cargoconfig =
if builtinz.pathExists (toString config.root + "/.cargo/config")
then builtins.readFile (config.root + "/.cargo/config")
then (config.root + "/.cargo/config")
else null;
build = args: import ./build.nix (
{
Expand Down
20 changes: 20 additions & 0 deletions test/fast/cargo-config/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{ sources, pkgs, ... }:

let
fenix = import sources.fenix { };

# Support for custom environmental variables was introduced in Cargo 1.56 and
# our tests use nixpkgs-21.05 which contains an older version of Cargo, making
# this test fail otherwise.
toolchain = fenix.latest;

naersk = pkgs.callPackage ../../../default.nix {
cargo = toolchain.cargo;
rustc = toolchain.rustc;
};

in
naersk.buildPackage {
src = ./fixtures;
doCheck = true;
}
2 changes: 2 additions & 0 deletions test/fast/cargo-config/fixtures/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[env]
ENV_HELLO_WORLD="Hello, World!"
7 changes: 7 additions & 0 deletions test/fast/cargo-config/fixtures/Cargo.lock

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

4 changes: 4 additions & 0 deletions test/fast/cargo-config/fixtures/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
name = "cargo-config"
version = "0.1.0"
edition = "2018"
11 changes: 11 additions & 0 deletions test/fast/cargo-config/fixtures/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
fn main() {
println!("{}", env!("ENV_HELLO_WORLD"));
}

#[cfg(test)]
mod tests {
#[test]
fn test() {
assert_eq!("Hello, World!", env!("ENV_HELLO_WORLD"));
}
}
1 change: 1 addition & 0 deletions test/fast/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
args: {
cargo-config = import ./cargo-config args;
cargo-wildcard = import ./cargo-wildcard args;
default-run = import ./default-run args;
dummyfication = import ./dummyfication args;
Expand Down
Loading