mirror of
https://github.com/NixOS/nix
synced 2025-07-13 17:10:47 +02:00
Merge commit 'b24757f08a
' into sync-2.24.2
This commit is contained in:
commit
c1d27763c6
330 changed files with 4907 additions and 1814 deletions
|
@ -27,6 +27,8 @@ deps_public_maybe_subproject = [
|
|||
]
|
||||
subdir('build-utils-meson/subprojects')
|
||||
|
||||
subdir('build-utils-meson/threads')
|
||||
|
||||
rapidcheck = dependency('rapidcheck')
|
||||
deps_public += rapidcheck
|
||||
|
||||
|
|
|
@ -66,12 +66,8 @@ mkMesonDerivation (finalAttrs: {
|
|||
LDFLAGS = "-fuse-ld=gold";
|
||||
};
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
separateDebugInfo = !stdenv.hostPlatform.isStatic;
|
||||
|
||||
strictDeps = true;
|
||||
|
||||
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
|
||||
|
||||
meta = {
|
||||
|
|
|
@ -34,6 +34,9 @@ int main (int argc, char **argv) {
|
|||
setEnv("_NIX_TEST_NO_SANDBOX", "1");
|
||||
#endif
|
||||
|
||||
// For pipe operator tests in trivial.cc
|
||||
experimentalFeatureSettings.set("experimental-features", "pipe-operators");
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ deps_public_maybe_subproject = [
|
|||
]
|
||||
subdir('build-utils-meson/subprojects')
|
||||
|
||||
subdir('build-utils-meson/threads')
|
||||
|
||||
subdir('build-utils-meson/export-all-symbols')
|
||||
|
||||
rapidcheck = dependency('rapidcheck')
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{ lib
|
||||
, buildPackages
|
||||
, stdenv
|
||||
, mkMesonDerivation
|
||||
, releaseTools
|
||||
|
@ -41,8 +42,6 @@ mkMesonDerivation (finalAttrs: {
|
|||
(fileset.fileFilter (file: file.hasExt "hh") ./.)
|
||||
];
|
||||
|
||||
outputs = [ "out" "dev" ];
|
||||
|
||||
nativeBuildInputs = [
|
||||
meson
|
||||
ninja
|
||||
|
@ -72,28 +71,28 @@ mkMesonDerivation (finalAttrs: {
|
|||
LDFLAGS = "-fuse-ld=gold";
|
||||
};
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
separateDebugInfo = !stdenv.hostPlatform.isStatic;
|
||||
|
||||
strictDeps = true;
|
||||
|
||||
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
|
||||
|
||||
passthru = {
|
||||
tests = {
|
||||
run = runCommand "${finalAttrs.pname}-run" {
|
||||
} ''
|
||||
PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH"
|
||||
meta.broken = !stdenv.hostPlatform.emulatorAvailable buildPackages;
|
||||
} (lib.optionalString stdenv.hostPlatform.isWindows ''
|
||||
export HOME="$PWD/home-dir"
|
||||
mkdir -p "$HOME"
|
||||
'' + ''
|
||||
export _NIX_TEST_UNIT_DATA=${resolvePath ./data}
|
||||
nix-expr-tests
|
||||
${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage}
|
||||
touch $out
|
||||
'';
|
||||
'');
|
||||
};
|
||||
};
|
||||
|
||||
meta = {
|
||||
platforms = lib.platforms.unix ++ lib.platforms.windows;
|
||||
mainProgram = finalAttrs.pname + stdenv.hostPlatform.extensions.executable;
|
||||
};
|
||||
|
||||
})
|
||||
|
|
|
@ -182,6 +182,60 @@ namespace nix {
|
|||
ASSERT_THAT(v, IsIntEq(15));
|
||||
}
|
||||
|
||||
TEST_F(TrivialExpressionTest, forwardPipe) {
|
||||
auto v = eval("1 |> builtins.add 2 |> builtins.mul 3");
|
||||
ASSERT_THAT(v, IsIntEq(9));
|
||||
}
|
||||
|
||||
TEST_F(TrivialExpressionTest, backwardPipe) {
|
||||
auto v = eval("builtins.add 1 <| builtins.mul 2 <| 3");
|
||||
ASSERT_THAT(v, IsIntEq(7));
|
||||
}
|
||||
|
||||
TEST_F(TrivialExpressionTest, forwardPipeEvaluationOrder) {
|
||||
auto v = eval("1 |> null |> (x: 2)");
|
||||
ASSERT_THAT(v, IsIntEq(2));
|
||||
}
|
||||
|
||||
TEST_F(TrivialExpressionTest, backwardPipeEvaluationOrder) {
|
||||
auto v = eval("(x: 1) <| null <| 2");
|
||||
ASSERT_THAT(v, IsIntEq(1));
|
||||
}
|
||||
|
||||
TEST_F(TrivialExpressionTest, differentPipeOperatorsDoNotAssociate) {
|
||||
ASSERT_THROW(eval("(x: 1) <| 2 |> (x: 3)"), ParseError);
|
||||
}
|
||||
|
||||
TEST_F(TrivialExpressionTest, differentPipeOperatorsParensLeft) {
|
||||
auto v = eval("((x: 1) <| 2) |> (x: 3)");
|
||||
ASSERT_THAT(v, IsIntEq(3));
|
||||
}
|
||||
|
||||
TEST_F(TrivialExpressionTest, differentPipeOperatorsParensRight) {
|
||||
auto v = eval("(x: 1) <| (2 |> (x: 3))");
|
||||
ASSERT_THAT(v, IsIntEq(1));
|
||||
}
|
||||
|
||||
TEST_F(TrivialExpressionTest, forwardPipeLowestPrecedence) {
|
||||
auto v = eval("false -> true |> (x: !x)");
|
||||
ASSERT_THAT(v, IsFalse());
|
||||
}
|
||||
|
||||
TEST_F(TrivialExpressionTest, backwardPipeLowestPrecedence) {
|
||||
auto v = eval("(x: !x) <| false -> true");
|
||||
ASSERT_THAT(v, IsFalse());
|
||||
}
|
||||
|
||||
TEST_F(TrivialExpressionTest, forwardPipeStrongerThanElse) {
|
||||
auto v = eval("if true then 1 else 2 |> 3");
|
||||
ASSERT_THAT(v, IsIntEq(1));
|
||||
}
|
||||
|
||||
TEST_F(TrivialExpressionTest, backwardPipeStrongerThanElse) {
|
||||
auto v = eval("if true then 1 else 2 <| 3");
|
||||
ASSERT_THAT(v, IsIntEq(1));
|
||||
}
|
||||
|
||||
TEST_F(TrivialExpressionTest, bindOr) {
|
||||
auto v = eval("{ or = 1; }");
|
||||
ASSERT_THAT(v, IsAttrsOfSize(1));
|
||||
|
|
|
@ -77,7 +77,7 @@ TEST_F(GitUtilsTest, sink_basic)
|
|||
|
||||
// sink->createHardlink("foo-1.1/links/foo-2", CanonPath("foo-1.1/hello"));
|
||||
|
||||
auto result = sink->sync();
|
||||
auto result = repo->dereferenceSingletonDirectory(sink->sync());
|
||||
auto accessor = repo->getAccessor(result, false);
|
||||
auto entries = accessor->readDirectory(CanonPath::root);
|
||||
ASSERT_EQ(entries.size(), 5);
|
||||
|
@ -103,7 +103,7 @@ TEST_F(GitUtilsTest, sink_hardlink)
|
|||
sink->createHardlink(CanonPath("foo-1.1/link"), CanonPath("hello"));
|
||||
FAIL() << "Expected an exception";
|
||||
} catch (const nix::Error & e) {
|
||||
ASSERT_THAT(e.msg(), testing::HasSubstr("invalid hard link target"));
|
||||
ASSERT_THAT(e.msg(), testing::HasSubstr("cannot find hard link target"));
|
||||
ASSERT_THAT(e.msg(), testing::HasSubstr("/hello"));
|
||||
ASSERT_THAT(e.msg(), testing::HasSubstr("foo-1.1/link"));
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ deps_public_maybe_subproject = [
|
|||
]
|
||||
subdir('build-utils-meson/subprojects')
|
||||
|
||||
subdir('build-utils-meson/threads')
|
||||
|
||||
subdir('build-utils-meson/export-all-symbols')
|
||||
|
||||
rapidcheck = dependency('rapidcheck')
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{ lib
|
||||
, buildPackages
|
||||
, stdenv
|
||||
, mkMesonDerivation
|
||||
, releaseTools
|
||||
|
@ -40,8 +41,6 @@ mkMesonDerivation (finalAttrs: {
|
|||
(fileset.fileFilter (file: file.hasExt "hh") ./.)
|
||||
];
|
||||
|
||||
outputs = [ "out" "dev" ];
|
||||
|
||||
nativeBuildInputs = [
|
||||
meson
|
||||
ninja
|
||||
|
@ -70,28 +69,28 @@ mkMesonDerivation (finalAttrs: {
|
|||
LDFLAGS = "-fuse-ld=gold";
|
||||
};
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
separateDebugInfo = !stdenv.hostPlatform.isStatic;
|
||||
|
||||
strictDeps = true;
|
||||
|
||||
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
|
||||
|
||||
passthru = {
|
||||
tests = {
|
||||
run = runCommand "${finalAttrs.pname}-run" {
|
||||
} ''
|
||||
PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH"
|
||||
meta.broken = !stdenv.hostPlatform.emulatorAvailable buildPackages;
|
||||
} (lib.optionalString stdenv.hostPlatform.isWindows ''
|
||||
export HOME="$PWD/home-dir"
|
||||
mkdir -p "$HOME"
|
||||
'' + ''
|
||||
export _NIX_TEST_UNIT_DATA=${resolvePath ./data}
|
||||
nix-fetchers-tests
|
||||
${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage}
|
||||
touch $out
|
||||
'';
|
||||
'');
|
||||
};
|
||||
};
|
||||
|
||||
meta = {
|
||||
platforms = lib.platforms.unix ++ lib.platforms.windows;
|
||||
mainProgram = finalAttrs.pname + stdenv.hostPlatform.extensions.executable;
|
||||
};
|
||||
|
||||
})
|
||||
|
|
|
@ -24,6 +24,8 @@ deps_public_maybe_subproject = [
|
|||
]
|
||||
subdir('build-utils-meson/subprojects')
|
||||
|
||||
subdir('build-utils-meson/threads')
|
||||
|
||||
subdir('build-utils-meson/export-all-symbols')
|
||||
|
||||
rapidcheck = dependency('rapidcheck')
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{ lib
|
||||
, buildPackages
|
||||
, stdenv
|
||||
, mkMesonDerivation
|
||||
, releaseTools
|
||||
|
@ -40,8 +41,6 @@ mkMesonDerivation (finalAttrs: {
|
|||
(fileset.fileFilter (file: file.hasExt "hh") ./.)
|
||||
];
|
||||
|
||||
outputs = [ "out" "dev" ];
|
||||
|
||||
nativeBuildInputs = [
|
||||
meson
|
||||
ninja
|
||||
|
@ -70,28 +69,28 @@ mkMesonDerivation (finalAttrs: {
|
|||
LDFLAGS = "-fuse-ld=gold";
|
||||
};
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
separateDebugInfo = !stdenv.hostPlatform.isStatic;
|
||||
|
||||
strictDeps = true;
|
||||
|
||||
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
|
||||
|
||||
passthru = {
|
||||
tests = {
|
||||
run = runCommand "${finalAttrs.pname}-run" {
|
||||
} ''
|
||||
PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH"
|
||||
meta.broken = !stdenv.hostPlatform.emulatorAvailable buildPackages;
|
||||
} (lib.optionalString stdenv.hostPlatform.isWindows ''
|
||||
export HOME="$PWD/home-dir"
|
||||
mkdir -p "$HOME"
|
||||
'' + ''
|
||||
export _NIX_TEST_UNIT_DATA=${resolvePath ./data}
|
||||
nix-flake-tests
|
||||
${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage}
|
||||
touch $out
|
||||
'';
|
||||
'');
|
||||
};
|
||||
};
|
||||
|
||||
meta = {
|
||||
platforms = lib.platforms.unix ++ lib.platforms.windows;
|
||||
mainProgram = finalAttrs.pname + stdenv.hostPlatform.extensions.executable;
|
||||
};
|
||||
|
||||
})
|
||||
|
|
|
@ -25,6 +25,8 @@ deps_public_maybe_subproject = [
|
|||
]
|
||||
subdir('build-utils-meson/subprojects')
|
||||
|
||||
subdir('build-utils-meson/threads')
|
||||
|
||||
rapidcheck = dependency('rapidcheck')
|
||||
deps_public += rapidcheck
|
||||
|
||||
|
|
|
@ -66,12 +66,8 @@ mkMesonDerivation (finalAttrs: {
|
|||
LDFLAGS = "-fuse-ld=gold";
|
||||
};
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
separateDebugInfo = !stdenv.hostPlatform.isStatic;
|
||||
|
||||
strictDeps = true;
|
||||
|
||||
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
|
||||
|
||||
meta = {
|
||||
|
|
21
tests/unit/libstore/http-binary-cache-store.cc
Normal file
21
tests/unit/libstore/http-binary-cache-store.cc
Normal file
|
@ -0,0 +1,21 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include "http-binary-cache-store.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
TEST(HttpBinaryCacheStore, constructConfig)
|
||||
{
|
||||
HttpBinaryCacheStoreConfig config{"http", "foo.bar.baz", {}};
|
||||
|
||||
EXPECT_EQ(config.cacheUri, "http://foo.bar.baz");
|
||||
}
|
||||
|
||||
TEST(HttpBinaryCacheStore, constructConfigNoTrailingSlash)
|
||||
{
|
||||
HttpBinaryCacheStoreConfig config{"https", "foo.bar.baz/a/b/", {}};
|
||||
|
||||
EXPECT_EQ(config.cacheUri, "https://foo.bar.baz/a/b");
|
||||
}
|
||||
|
||||
} // namespace nix
|
14
tests/unit/libstore/local-binary-cache-store.cc
Normal file
14
tests/unit/libstore/local-binary-cache-store.cc
Normal file
|
@ -0,0 +1,14 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include "local-binary-cache-store.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
TEST(LocalBinaryCacheStore, constructConfig)
|
||||
{
|
||||
LocalBinaryCacheStoreConfig config{"local", "/foo/bar/baz", {}};
|
||||
|
||||
EXPECT_EQ(config.binaryCacheDir, "/foo/bar/baz");
|
||||
}
|
||||
|
||||
} // namespace nix
|
34
tests/unit/libstore/local-overlay-store.cc
Normal file
34
tests/unit/libstore/local-overlay-store.cc
Normal file
|
@ -0,0 +1,34 @@
|
|||
// FIXME: Odd failures for templates that are causing the PR to break
|
||||
// for now with discussion with @Ericson2314 to comment out.
|
||||
#if 0
|
||||
# include <gtest/gtest.h>
|
||||
|
||||
# include "local-overlay-store.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
TEST(LocalOverlayStore, constructConfig_rootQueryParam)
|
||||
{
|
||||
LocalOverlayStoreConfig config{
|
||||
"local-overlay",
|
||||
"",
|
||||
{
|
||||
{
|
||||
"root",
|
||||
"/foo/bar",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
EXPECT_EQ(config.rootDir.get(), std::optional{"/foo/bar"});
|
||||
}
|
||||
|
||||
TEST(LocalOverlayStore, constructConfig_rootPath)
|
||||
{
|
||||
LocalOverlayStoreConfig config{"local-overlay", "/foo/bar", {}};
|
||||
|
||||
EXPECT_EQ(config.rootDir.get(), std::optional{"/foo/bar"});
|
||||
}
|
||||
|
||||
} // namespace nix
|
||||
#endif
|
40
tests/unit/libstore/local-store.cc
Normal file
40
tests/unit/libstore/local-store.cc
Normal file
|
@ -0,0 +1,40 @@
|
|||
// FIXME: Odd failures for templates that are causing the PR to break
|
||||
// for now with discussion with @Ericson2314 to comment out.
|
||||
#if 0
|
||||
# include <gtest/gtest.h>
|
||||
|
||||
# include "local-store.hh"
|
||||
|
||||
// Needed for template specialisations. This is not good! When we
|
||||
// overhaul how store configs work, this should be fixed.
|
||||
# include "args.hh"
|
||||
# include "config-impl.hh"
|
||||
# include "abstract-setting-to-json.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
TEST(LocalStore, constructConfig_rootQueryParam)
|
||||
{
|
||||
LocalStoreConfig config{
|
||||
"local",
|
||||
"",
|
||||
{
|
||||
{
|
||||
"root",
|
||||
"/foo/bar",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
EXPECT_EQ(config.rootDir.get(), std::optional{"/foo/bar"});
|
||||
}
|
||||
|
||||
TEST(LocalStore, constructConfig_rootPath)
|
||||
{
|
||||
LocalStoreConfig config{"local", "/foo/bar", {}};
|
||||
|
||||
EXPECT_EQ(config.rootDir.get(), std::optional{"/foo/bar"});
|
||||
}
|
||||
|
||||
} // namespace nix
|
||||
#endif
|
|
@ -25,6 +25,8 @@ deps_public_maybe_subproject = [
|
|||
]
|
||||
subdir('build-utils-meson/subprojects')
|
||||
|
||||
subdir('build-utils-meson/threads')
|
||||
|
||||
subdir('build-utils-meson/export-all-symbols')
|
||||
|
||||
sqlite = dependency('sqlite3', 'sqlite', version : '>=3.6.19')
|
||||
|
@ -58,7 +60,11 @@ sources = files(
|
|||
'derivation.cc',
|
||||
'derived-path.cc',
|
||||
'downstream-placeholder.cc',
|
||||
'http-binary-cache-store.cc',
|
||||
'legacy-ssh-store.cc',
|
||||
'local-binary-cache-store.cc',
|
||||
'local-overlay-store.cc',
|
||||
'local-store.cc',
|
||||
'machines.cc',
|
||||
'nar-info-disk-cache.cc',
|
||||
'nar-info.cc',
|
||||
|
@ -67,9 +73,11 @@ sources = files(
|
|||
'path-info.cc',
|
||||
'path.cc',
|
||||
'references.cc',
|
||||
's3-binary-cache-store.cc',
|
||||
'serve-protocol.cc',
|
||||
'ssh-store.cc',
|
||||
'store-reference.cc',
|
||||
'uds-remote-store.cc',
|
||||
'worker-protocol.cc',
|
||||
)
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{ lib
|
||||
, buildPackages
|
||||
, stdenv
|
||||
, mkMesonDerivation
|
||||
, releaseTools
|
||||
|
@ -42,8 +43,6 @@ mkMesonDerivation (finalAttrs: {
|
|||
(fileset.fileFilter (file: file.hasExt "hh") ./.)
|
||||
];
|
||||
|
||||
outputs = [ "out" "dev" ];
|
||||
|
||||
nativeBuildInputs = [
|
||||
meson
|
||||
ninja
|
||||
|
@ -74,12 +73,8 @@ mkMesonDerivation (finalAttrs: {
|
|||
LDFLAGS = "-fuse-ld=gold";
|
||||
};
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
separateDebugInfo = !stdenv.hostPlatform.isStatic;
|
||||
|
||||
strictDeps = true;
|
||||
|
||||
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
|
||||
|
||||
passthru = {
|
||||
|
@ -94,17 +89,22 @@ mkMesonDerivation (finalAttrs: {
|
|||
../../functional/derivation
|
||||
];
|
||||
};
|
||||
in runCommand "${finalAttrs.pname}-run" {} ''
|
||||
PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH"
|
||||
in runCommand "${finalAttrs.pname}-run" {
|
||||
meta.broken = !stdenv.hostPlatform.emulatorAvailable buildPackages;
|
||||
} (lib.optionalString stdenv.hostPlatform.isWindows ''
|
||||
export HOME="$PWD/home-dir"
|
||||
mkdir -p "$HOME"
|
||||
'' + ''
|
||||
export _NIX_TEST_UNIT_DATA=${data + "/unit/libstore/data"}
|
||||
nix-store-tests
|
||||
${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage}
|
||||
touch $out
|
||||
'';
|
||||
'');
|
||||
};
|
||||
};
|
||||
|
||||
meta = {
|
||||
platforms = lib.platforms.unix ++ lib.platforms.windows;
|
||||
mainProgram = finalAttrs.pname + stdenv.hostPlatform.extensions.executable;
|
||||
};
|
||||
|
||||
})
|
||||
|
|
18
tests/unit/libstore/s3-binary-cache-store.cc
Normal file
18
tests/unit/libstore/s3-binary-cache-store.cc
Normal file
|
@ -0,0 +1,18 @@
|
|||
#if ENABLE_S3
|
||||
|
||||
# include <gtest/gtest.h>
|
||||
|
||||
# include "s3-binary-cache-store.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
TEST(S3BinaryCacheStore, constructConfig)
|
||||
{
|
||||
S3BinaryCacheStoreConfig config{"s3", "foobar", {}};
|
||||
|
||||
EXPECT_EQ(config.bucketName, "foobar");
|
||||
}
|
||||
|
||||
} // namespace nix
|
||||
|
||||
#endif
|
|
@ -1,6 +1,9 @@
|
|||
#include <gtest/gtest.h>
|
||||
// FIXME: Odd failures for templates that are causing the PR to break
|
||||
// for now with discussion with @Ericson2314 to comment out.
|
||||
#if 0
|
||||
# include <gtest/gtest.h>
|
||||
|
||||
#include "ssh-store.hh"
|
||||
# include "ssh-store.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
|
@ -15,7 +18,9 @@ TEST(SSHStore, constructConfig)
|
|||
// TODO #11106, no more split on space
|
||||
"foo bar",
|
||||
},
|
||||
}};
|
||||
},
|
||||
};
|
||||
|
||||
EXPECT_EQ(
|
||||
config.remoteProgram.get(),
|
||||
(Strings{
|
||||
|
@ -23,4 +28,28 @@ TEST(SSHStore, constructConfig)
|
|||
"bar",
|
||||
}));
|
||||
}
|
||||
|
||||
TEST(MountedSSHStore, constructConfig)
|
||||
{
|
||||
MountedSSHStoreConfig config{
|
||||
"mounted-ssh",
|
||||
"localhost",
|
||||
StoreConfig::Params{
|
||||
{
|
||||
"remote-program",
|
||||
// TODO #11106, no more split on space
|
||||
"foo bar",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
EXPECT_EQ(
|
||||
config.remoteProgram.get(),
|
||||
(Strings{
|
||||
"foo",
|
||||
"bar",
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
23
tests/unit/libstore/uds-remote-store.cc
Normal file
23
tests/unit/libstore/uds-remote-store.cc
Normal file
|
@ -0,0 +1,23 @@
|
|||
// FIXME: Odd failures for templates that are causing the PR to break
|
||||
// for now with discussion with @Ericson2314 to comment out.
|
||||
#if 0
|
||||
# include <gtest/gtest.h>
|
||||
|
||||
# include "uds-remote-store.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
TEST(UDSRemoteStore, constructConfig)
|
||||
{
|
||||
UDSRemoteStoreConfig config{"unix", "/tmp/socket", {}};
|
||||
|
||||
EXPECT_EQ(config.path, "/tmp/socket");
|
||||
}
|
||||
|
||||
TEST(UDSRemoteStore, constructConfigWrongScheme)
|
||||
{
|
||||
EXPECT_THROW(UDSRemoteStoreConfig("http", "/tmp/socket", {}), UsageError);
|
||||
}
|
||||
|
||||
} // namespace nix
|
||||
#endif
|
|
@ -658,15 +658,15 @@ TEST_F(WorkerProtoTest, handshake_log)
|
|||
FdSink out { toServer.writeSide.get() };
|
||||
FdSource in0 { toClient.readSide.get() };
|
||||
TeeSource in { in0, toClientLog };
|
||||
clientResult = WorkerProto::BasicClientConnection::handshake(
|
||||
out, in, defaultVersion);
|
||||
clientResult = std::get<0>(WorkerProto::BasicClientConnection::handshake(
|
||||
out, in, defaultVersion, {}));
|
||||
});
|
||||
|
||||
{
|
||||
FdSink out { toClient.writeSide.get() };
|
||||
FdSource in { toServer.readSide.get() };
|
||||
WorkerProto::BasicServerConnection::handshake(
|
||||
out, in, defaultVersion);
|
||||
out, in, defaultVersion, {});
|
||||
};
|
||||
|
||||
thread.join();
|
||||
|
@ -675,6 +675,33 @@ TEST_F(WorkerProtoTest, handshake_log)
|
|||
});
|
||||
}
|
||||
|
||||
TEST_F(WorkerProtoTest, handshake_features)
|
||||
{
|
||||
Pipe toClient, toServer;
|
||||
toClient.create();
|
||||
toServer.create();
|
||||
|
||||
std::tuple<WorkerProto::Version, std::set<WorkerProto::Feature>> clientResult;
|
||||
|
||||
auto clientThread = std::thread([&]() {
|
||||
FdSink out { toServer.writeSide.get() };
|
||||
FdSource in { toClient.readSide.get() };
|
||||
clientResult = WorkerProto::BasicClientConnection::handshake(
|
||||
out, in, 123, {"bar", "aap", "mies", "xyzzy"});
|
||||
});
|
||||
|
||||
FdSink out { toClient.writeSide.get() };
|
||||
FdSource in { toServer.readSide.get() };
|
||||
auto daemonResult = WorkerProto::BasicServerConnection::handshake(
|
||||
out, in, 456, {"foo", "bar", "xyzzy"});
|
||||
|
||||
clientThread.join();
|
||||
|
||||
EXPECT_EQ(clientResult, daemonResult);
|
||||
EXPECT_EQ(std::get<0>(clientResult), 123);
|
||||
EXPECT_EQ(std::get<1>(clientResult), std::set<WorkerProto::Feature>({"bar", "xyzzy"}));
|
||||
}
|
||||
|
||||
/// Has to be a `BufferedSink` for handshake.
|
||||
struct NullBufferedSink : BufferedSink {
|
||||
void writeUnbuffered(std::string_view data) override { }
|
||||
|
@ -686,8 +713,8 @@ TEST_F(WorkerProtoTest, handshake_client_replay)
|
|||
NullBufferedSink nullSink;
|
||||
|
||||
StringSource in { toClientLog };
|
||||
auto clientResult = WorkerProto::BasicClientConnection::handshake(
|
||||
nullSink, in, defaultVersion);
|
||||
auto clientResult = std::get<0>(WorkerProto::BasicClientConnection::handshake(
|
||||
nullSink, in, defaultVersion, {}));
|
||||
|
||||
EXPECT_EQ(clientResult, defaultVersion);
|
||||
});
|
||||
|
@ -705,13 +732,13 @@ TEST_F(WorkerProtoTest, handshake_client_truncated_replay_throws)
|
|||
if (len < 8) {
|
||||
EXPECT_THROW(
|
||||
WorkerProto::BasicClientConnection::handshake(
|
||||
nullSink, in, defaultVersion),
|
||||
nullSink, in, defaultVersion, {}),
|
||||
EndOfFile);
|
||||
} else {
|
||||
// Not sure why cannot keep on checking for `EndOfFile`.
|
||||
EXPECT_THROW(
|
||||
WorkerProto::BasicClientConnection::handshake(
|
||||
nullSink, in, defaultVersion),
|
||||
nullSink, in, defaultVersion, {}),
|
||||
Error);
|
||||
}
|
||||
}
|
||||
|
@ -734,17 +761,17 @@ TEST_F(WorkerProtoTest, handshake_client_corrupted_throws)
|
|||
// magic bytes don't match
|
||||
EXPECT_THROW(
|
||||
WorkerProto::BasicClientConnection::handshake(
|
||||
nullSink, in, defaultVersion),
|
||||
nullSink, in, defaultVersion, {}),
|
||||
Error);
|
||||
} else if (idx < 8 || idx >= 12) {
|
||||
// Number out of bounds
|
||||
EXPECT_THROW(
|
||||
WorkerProto::BasicClientConnection::handshake(
|
||||
nullSink, in, defaultVersion),
|
||||
nullSink, in, defaultVersion, {}),
|
||||
SerialisationError);
|
||||
} else {
|
||||
auto ver = WorkerProto::BasicClientConnection::handshake(
|
||||
nullSink, in, defaultVersion);
|
||||
auto ver = std::get<0>(WorkerProto::BasicClientConnection::handshake(
|
||||
nullSink, in, defaultVersion, {}));
|
||||
// `std::min` of this and the other version saves us
|
||||
EXPECT_EQ(ver, defaultVersion);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ deps_public_maybe_subproject = [
|
|||
]
|
||||
subdir('build-utils-meson/subprojects')
|
||||
|
||||
subdir('build-utils-meson/threads')
|
||||
|
||||
rapidcheck = dependency('rapidcheck')
|
||||
deps_public += rapidcheck
|
||||
|
||||
|
|
|
@ -64,12 +64,8 @@ mkMesonDerivation (finalAttrs: {
|
|||
LDFLAGS = "-fuse-ld=gold";
|
||||
};
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
separateDebugInfo = !stdenv.hostPlatform.isStatic;
|
||||
|
||||
strictDeps = true;
|
||||
|
||||
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
|
||||
|
||||
meta = {
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
|
||||
namespace nix::testing {
|
||||
|
||||
void observe_string_cb(const char * start, unsigned int n, std::string * user_data)
|
||||
void observe_string_cb(const char * start, unsigned int n, void * user_data)
|
||||
{
|
||||
*user_data = std::string(start);
|
||||
auto user_data_casted = reinterpret_cast<std::string *>(user_data);
|
||||
*user_data_casted = std::string(start);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,14 +3,13 @@
|
|||
|
||||
namespace nix::testing {
|
||||
|
||||
void observe_string_cb(const char * start, unsigned int n, std::string * user_data);
|
||||
void observe_string_cb(const char * start, unsigned int n, void * user_data);
|
||||
|
||||
inline void * observe_string_cb_data(std::string & out)
|
||||
{
|
||||
return (void *) &out;
|
||||
};
|
||||
|
||||
#define OBSERVE_STRING(str) \
|
||||
(nix_get_string_callback) nix::testing::observe_string_cb, nix::testing::observe_string_cb_data(str)
|
||||
#define OBSERVE_STRING(str) nix::testing::observe_string_cb, nix::testing::observe_string_cb_data(str)
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ deps_public_maybe_subproject = [
|
|||
]
|
||||
subdir('build-utils-meson/subprojects')
|
||||
|
||||
subdir('build-utils-meson/threads')
|
||||
|
||||
subdir('build-utils-meson/export-all-symbols')
|
||||
|
||||
rapidcheck = dependency('rapidcheck')
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{ lib
|
||||
, buildPackages
|
||||
, stdenv
|
||||
, mkMesonDerivation
|
||||
, releaseTools
|
||||
|
@ -40,8 +41,6 @@ mkMesonDerivation (finalAttrs: {
|
|||
(fileset.fileFilter (file: file.hasExt "hh") ./.)
|
||||
];
|
||||
|
||||
outputs = [ "out" "dev" ];
|
||||
|
||||
nativeBuildInputs = [
|
||||
meson
|
||||
ninja
|
||||
|
@ -71,28 +70,28 @@ mkMesonDerivation (finalAttrs: {
|
|||
LDFLAGS = "-fuse-ld=gold";
|
||||
};
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
separateDebugInfo = !stdenv.hostPlatform.isStatic;
|
||||
|
||||
strictDeps = true;
|
||||
|
||||
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
|
||||
|
||||
passthru = {
|
||||
tests = {
|
||||
run = runCommand "${finalAttrs.pname}-run" {
|
||||
} ''
|
||||
PATH="${lib.makeBinPath [ finalAttrs.finalPackage ]}:$PATH"
|
||||
meta.broken = !stdenv.hostPlatform.emulatorAvailable buildPackages;
|
||||
} (lib.optionalString stdenv.hostPlatform.isWindows ''
|
||||
export HOME="$PWD/home-dir"
|
||||
mkdir -p "$HOME"
|
||||
'' + ''
|
||||
export _NIX_TEST_UNIT_DATA=${./data}
|
||||
nix-util-tests
|
||||
${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage}
|
||||
touch $out
|
||||
'';
|
||||
'');
|
||||
};
|
||||
};
|
||||
|
||||
meta = {
|
||||
platforms = lib.platforms.unix ++ lib.platforms.windows;
|
||||
mainProgram = finalAttrs.pname + stdenv.hostPlatform.extensions.executable;
|
||||
};
|
||||
|
||||
})
|
||||
|
|
|
@ -17,6 +17,10 @@
|
|||
# define FS_ROOT FS_SEP
|
||||
#endif
|
||||
|
||||
#ifndef PATH_MAX
|
||||
# define PATH_MAX 4096
|
||||
#endif
|
||||
|
||||
namespace nix {
|
||||
|
||||
/* ----------- tests for util.hh ------------------------------------------------*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue