mirror of
https://github.com/NixOS/nix
synced 2025-07-08 19:23:54 +02:00
Merge remote-tracking branch 'origin/master' into relative-flakes
This commit is contained in:
commit
91e7d493ce
51 changed files with 1577 additions and 188 deletions
|
@ -2,5 +2,5 @@ source common.sh
|
|||
|
||||
export NIX_TESTS_CA_BY_DEFAULT=1
|
||||
|
||||
cd .. && source import-derivation.sh
|
||||
cd .. && source import-from-derivation.sh
|
||||
|
|
@ -7,7 +7,7 @@ ca-tests := \
|
|||
$(d)/duplicate-realisation-in-closure.sh \
|
||||
$(d)/eval-store.sh \
|
||||
$(d)/gc.sh \
|
||||
$(d)/import-derivation.sh \
|
||||
$(d)/import-from-derivation.sh \
|
||||
$(d)/new-build-cmd.sh \
|
||||
$(d)/nix-copy.sh \
|
||||
$(d)/nix-run.sh \
|
||||
|
|
|
@ -16,7 +16,7 @@ suites += {
|
|||
'duplicate-realisation-in-closure.sh',
|
||||
'eval-store.sh',
|
||||
'gc.sh',
|
||||
'import-derivation.sh',
|
||||
'import-from-derivation.sh',
|
||||
'new-build-cmd.sh',
|
||||
'nix-copy.sh',
|
||||
'nix-run.sh',
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
with import ./config.nix;
|
||||
|
||||
let
|
||||
|
||||
bar = mkDerivation {
|
||||
name = "bar";
|
||||
builder = builtins.toFile "builder.sh"
|
||||
''
|
||||
echo 'builtins.add 123 456' > $out
|
||||
'';
|
||||
};
|
||||
|
||||
value =
|
||||
# Test that pathExists can check the existence of /nix/store paths
|
||||
assert builtins.pathExists bar;
|
||||
import bar;
|
||||
|
||||
in
|
||||
|
||||
mkDerivation {
|
||||
name = "foo";
|
||||
builder = builtins.toFile "builder.sh"
|
||||
''
|
||||
echo -n FOO${toString value} > $out
|
||||
'';
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
source common.sh
|
||||
|
||||
clearStoreIfPossible
|
||||
|
||||
if nix-instantiate --readonly-mode ./import-derivation.nix; then
|
||||
echo "read-only evaluation of an imported derivation unexpectedly failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
outPath=$(nix-build ./import-derivation.nix --no-out-link)
|
||||
|
||||
[ "$(cat "$outPath")" = FOO579 ]
|
33
tests/functional/import-from-derivation.nix
Normal file
33
tests/functional/import-from-derivation.nix
Normal file
|
@ -0,0 +1,33 @@
|
|||
with import ./config.nix;
|
||||
|
||||
rec {
|
||||
bar = mkDerivation {
|
||||
name = "bar";
|
||||
builder = builtins.toFile "builder.sh"
|
||||
''
|
||||
echo 'builtins.add 123 456' > $out
|
||||
'';
|
||||
};
|
||||
|
||||
value =
|
||||
# Test that pathExists can check the existence of /nix/store paths
|
||||
assert builtins.pathExists bar;
|
||||
import bar;
|
||||
|
||||
result = mkDerivation {
|
||||
name = "foo";
|
||||
builder = builtins.toFile "builder.sh"
|
||||
''
|
||||
echo -n FOO${toString value} > $out
|
||||
'';
|
||||
};
|
||||
|
||||
addPath = mkDerivation {
|
||||
name = "add-path";
|
||||
src = builtins.filterSource (path: type: true) result;
|
||||
builder = builtins.toFile "builder.sh"
|
||||
''
|
||||
echo -n BLA$(cat $src) > $out
|
||||
'';
|
||||
};
|
||||
}
|
50
tests/functional/import-from-derivation.sh
Executable file
50
tests/functional/import-from-derivation.sh
Executable file
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
source common.sh
|
||||
|
||||
TODO_NixOS
|
||||
|
||||
clearStoreIfPossible
|
||||
|
||||
if nix-instantiate --readonly-mode ./import-from-derivation.nix -A result; then
|
||||
echo "read-only evaluation of an imported derivation unexpectedly failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
outPath=$(nix-build ./import-from-derivation.nix -A result --no-out-link)
|
||||
|
||||
[ "$(cat "$outPath")" = FOO579 ]
|
||||
|
||||
# FIXME: the next tests are broken on CA.
|
||||
if [[ -n "${NIX_TESTS_CA_BY_DEFAULT:-}" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Test filterSource on the result of a derivation.
|
||||
outPath2=$(nix-build ./import-from-derivation.nix -A addPath --no-out-link)
|
||||
[[ "$(cat "$outPath2")" = BLAFOO579 ]]
|
||||
|
||||
# Test that IFD works with a chroot store.
|
||||
if canUseSandbox; then
|
||||
|
||||
store2="$TEST_ROOT/store2"
|
||||
store2_url="$store2?store=$NIX_STORE_DIR"
|
||||
|
||||
# Copy the derivation outputs to the chroot store to avoid having
|
||||
# to actually build anything, as that would fail due to the lack
|
||||
# of a shell in the sandbox. We only care about testing the IFD
|
||||
# semantics.
|
||||
for i in bar result addPath; do
|
||||
nix copy --to "$store2_url" --no-check-sigs "$(nix-build ./import-from-derivation.nix -A "$i" --no-out-link)"
|
||||
done
|
||||
|
||||
clearStore
|
||||
|
||||
outPath_check=$(nix-build ./import-from-derivation.nix -A result --no-out-link --store "$store2_url")
|
||||
[[ "$outPath" = "$outPath_check" ]]
|
||||
[[ ! -e "$outPath" ]]
|
||||
[[ -e "$store2/nix/store/$(basename "$outPath")" ]]
|
||||
|
||||
outPath2_check=$(nix-build ./import-from-derivation.nix -A addPath --no-out-link --store "$store2_url")
|
||||
[[ "$outPath2" = "$outPath2_check" ]]
|
||||
fi
|
|
@ -88,7 +88,7 @@ nix_tests = \
|
|||
why-depends.sh \
|
||||
derivation-json.sh \
|
||||
derivation-advanced-attributes.sh \
|
||||
import-derivation.sh \
|
||||
import-from-derivation.sh \
|
||||
nix_path.sh \
|
||||
nars.sh \
|
||||
placeholders.sh \
|
||||
|
|
|
@ -157,7 +157,7 @@ suites = [
|
|||
'why-depends.sh',
|
||||
'derivation-json.sh',
|
||||
'derivation-advanced-attributes.sh',
|
||||
'import-derivation.sh',
|
||||
'import-from-derivation.sh',
|
||||
'nix_path.sh',
|
||||
'nars.sh',
|
||||
'placeholders.sh',
|
||||
|
|
|
@ -95,13 +95,6 @@ mkMesonDerivation (finalAttrs: {
|
|||
"--print-errorlogs"
|
||||
];
|
||||
|
||||
preCheck =
|
||||
# See https://github.com/NixOS/nix/issues/2523
|
||||
# Occurs often in tests since https://github.com/NixOS/nix/pull/9900
|
||||
lib.optionalString stdenv.hostPlatform.isDarwin ''
|
||||
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
|
||||
'';
|
||||
|
||||
doCheck = true;
|
||||
|
||||
installPhase = ''
|
||||
|
|
|
@ -31,11 +31,13 @@ env > $TEST_ROOT/expected-env
|
|||
nix shell -f shell-hello.nix hello -c env > $TEST_ROOT/actual-env
|
||||
# Remove/reset variables we expect to be different.
|
||||
# - PATH is modified by nix shell
|
||||
# - we unset TMPDIR on macOS if it contains /var/folders
|
||||
# - _ is set by bash and is expectedf to differ because it contains the original command
|
||||
# - __CF_USER_TEXT_ENCODING is set by macOS and is beyond our control
|
||||
sed -i \
|
||||
-e 's/PATH=.*/PATH=.../' \
|
||||
-e 's/_=.*/_=.../' \
|
||||
-e '/^TMPDIR=\/var\/folders\/.*/d' \
|
||||
-e '/^__CF_USER_TEXT_ENCODING=.*$/d' \
|
||||
$TEST_ROOT/expected-env $TEST_ROOT/actual-env
|
||||
sort $TEST_ROOT/expected-env > $TEST_ROOT/expected-env.sorted
|
||||
|
|
|
@ -217,16 +217,10 @@ let
|
|||
$ssh <<EOF
|
||||
set -ex
|
||||
|
||||
# enable nounset while loading the profile
|
||||
# this may or may not work on all distros, depending on the quality of their scripts
|
||||
set -u
|
||||
|
||||
# FIXME: get rid of this; ideally ssh should just work.
|
||||
source ~/.bash_profile || true
|
||||
source ~/.bash_login || true
|
||||
source ~/.profile || true
|
||||
set +u
|
||||
|
||||
source /etc/bashrc || true
|
||||
|
||||
nix-env --version
|
||||
|
|
|
@ -77,7 +77,7 @@ TEST_F(GitUtilsTest, sink_basic)
|
|||
|
||||
// sink->createHardlink("foo-1.1/links/foo-2", CanonPath("foo-1.1/hello"));
|
||||
|
||||
auto result = repo->dereferenceSingletonDirectory(sink->sync());
|
||||
auto result = repo->dereferenceSingletonDirectory(sink->flush());
|
||||
auto accessor = repo->getAccessor(result, false);
|
||||
auto entries = accessor->readDirectory(CanonPath::root);
|
||||
ASSERT_EQ(entries.size(), 5);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "tests/nix_api_util.hh"
|
||||
|
||||
#include "file-system.hh"
|
||||
#include <filesystem>
|
||||
|
||||
#include "nix_api_store.h"
|
||||
#include "nix_api_store_internal.h"
|
||||
|
@ -47,7 +48,9 @@ protected:
|
|||
if (fs::create_directory(nixDir)) break;
|
||||
}
|
||||
#else
|
||||
auto tmpl = nix::defaultTempDir() + "/tests_nix-store.XXXXXX";
|
||||
// resolve any symlinks in i.e. on macOS /tmp -> /private/tmp
|
||||
// because this is not allowed for a nix store.
|
||||
auto tmpl = nix::absPath(std::filesystem::path(nix::defaultTempDir()) / "tests_nix-store.XXXXXX", true);
|
||||
nixDir = mkdtemp((char *) tmpl.c_str());
|
||||
#endif
|
||||
|
||||
|
@ -61,6 +64,10 @@ protected:
|
|||
const char ** params[] = {p1, p2, p3, nullptr};
|
||||
|
||||
store = nix_store_open(ctx, "local", params);
|
||||
if (!store) {
|
||||
std::string errMsg = nix_err_msg(nullptr, ctx, nullptr);
|
||||
ASSERT_NE(store, nullptr) << "Could not open store: " << errMsg;
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue