Skip to content
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
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,24 @@ jobs:
path: out/*
if: ${{ matrix.primary }}

windows_tests:
needs: basic-checks
name: windows unit tests
runs-on: ubuntu-24.04
continue-on-error: true
timeout-minutes: 60
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: ./.github/actions/install-nix-action
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
dogfood: ${{ github.event_name == 'workflow_dispatch' && inputs.dogfood || github.event_name != 'workflow_dispatch' }}
- name: Run Windows unit tests
run: |
nix build --file ci/gha/tests/windows.nix unitTests.nix-util-tests -L

installer_test:
needs: [tests]
strategy:
Expand Down
30 changes: 30 additions & 0 deletions ci/gha/tests/windows.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
nixFlake ? builtins.getFlake ("git+file://" + toString ../../..),
system ? builtins.currentSystem,
pkgs ? nixFlake.inputs.nixpkgs.legacyPackages.${system},
}:

let
packages = nixFlake.packages.${system};

fixOutput =
test:
test.overrideAttrs (prev: {
nativeBuildInputs = prev.nativeBuildInputs or [ ] ++ [ pkgs.colorized-logs ];
env.GTEST_COLOR = "no";
# Wine's console emulation wraps every character in ANSI cursor
# hide/show sequences, making logs unreadable in GitHub Actions.
buildCommand = ''
set -o pipefail
{
${prev.buildCommand}
} 2>&1 | ansi2txt
'';
});
in

{
unitTests = {
"nix-util-tests" = fixOutput packages."nix-util-tests-x86_64-w64-mingw32".passthru.tests.run;
};
}
3 changes: 3 additions & 0 deletions src/libutil-tests/file-descriptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,9 @@ TEST(BufferedSourceReadLine, BufferExhaustedThenEof)

TEST(WriteFull, RespectsAllowInterrupts)
{
#ifdef _WIN32
GTEST_SKIP() << "Broken on Windows";
#endif
Pipe pipe;
pipe.create();

Expand Down
6 changes: 6 additions & 0 deletions src/libutil-tests/file-system-at.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ namespace nix {

TEST(readLinkAt, works)
{
#ifdef _WIN32
GTEST_SKIP() << "Broken on Windows";
#endif
std::filesystem::path tmpDir = nix::createTempDir();
nix::AutoDelete delTmpDir(tmpDir, /*recursive=*/true);

Expand Down Expand Up @@ -66,6 +69,9 @@ TEST(readLinkAt, works)

TEST(openFileEnsureBeneathNoSymlinks, works)
{
#ifdef _WIN32
GTEST_SKIP() << "Broken on Windows";
#endif
std::filesystem::path tmpDir = nix::createTempDir();
nix::AutoDelete delTmpDir(tmpDir, /*recursive=*/true);

Expand Down
9 changes: 5 additions & 4 deletions src/libutil-tests/file-system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,13 @@ TEST(makeParentCanonical, root)
* chmodIfNeeded
* --------------------------------------------------------------------------*/

#ifndef _WIN32
// Windows doesn't support Unix-style permission bits - lstat always
// returns the same mode regardless of what chmod sets.
TEST(chmodIfNeeded, works)
{
#ifdef _WIN32
// Windows doesn't support Unix-style permission bits - lstat always
// returns the same mode regardless of what chmod sets.
GTEST_SKIP() << "Broken on Windows";
#endif
auto [autoClose_, tmpFile] = nix::createTempFile();
auto deleteTmpFile = AutoDelete(tmpFile);

Expand All @@ -299,7 +301,6 @@ TEST(chmodIfNeeded, works)
}
}
}
#endif

TEST(chmodIfNeeded, nonexistent)
{
Expand Down
6 changes: 6 additions & 0 deletions src/libutil-tests/source-accessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ class FSSourceAccessorTest : public ::testing::Test

TEST_F(FSSourceAccessorTest, works)
{
#ifdef _WIN32
GTEST_SKIP() << "Broken on Windows";
#endif
{
RestoreSink sink(false);
sink.dstPath = tmpDir;
Expand Down Expand Up @@ -156,6 +159,9 @@ TEST_F(FSSourceAccessorTest, RestoreSinkRegularFileAtRoot)

TEST_F(FSSourceAccessorTest, RestoreSinkSymlinkAtRoot)
{
#ifdef _WIN32
GTEST_SKIP() << "symlinks have some problems under Wine";
#endif
auto linkPath = tmpDir / "rootlink";
{
RestoreSink sink(false);
Expand Down
2 changes: 1 addition & 1 deletion src/libutil/posix-source-accessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ std::string PosixSourceAccessor::readLink(const CanonPath & path)
{
if (auto parent = path.parent())
assertNoSymlinks(*parent);
return nix::readLink(makeAbsPath(path).string()).string();
return nix::readLink(makeAbsPath(path)).string();
}

std::optional<std::filesystem::path> PosixSourceAccessor::getPhysicalPath(const CanonPath & path)
Expand Down
7 changes: 6 additions & 1 deletion src/libutil/unix-domain-socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ bindConnectProcHelper(std::string_view operationName, auto && operation, Socket

void bind(Socket fd, const std::filesystem::path & path)
{
unlink(path.string().c_str());
#ifdef _WIN32
_wunlink
#else
unlink
#endif
(path.c_str());

bindConnectProcHelper("bind", ::bind, fd, path.string());
}
Expand Down
Loading