diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba3deece..8d3935d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,6 +35,9 @@ jobs: - os: ubuntu-latest arch: x64 version: 'nightly' + - os: windows-latest + arch: x64 + version: 'lts' steps: - run: git config --global core.autocrlf false diff --git a/src/file.jl b/src/file.jl index 5907ec9d..87997dda 100644 --- a/src/file.jl +++ b/src/file.jl @@ -336,8 +336,14 @@ function File(ctx::Context, @nospecialize(chunking::Bool=false)) ctx.debug && println("types after parsing: $types, pool = $(ctx.pool)") # for windows, it's particularly finicky about throwing errors when you try to modify an mmapped file # so we just want to make sure we finalize the input buffer so users don't run into surprises + # on Julia 1.11 the underlying memory needs to be finalized to unmmap the file. + # Ref: https://github.com/JuliaLang/julia/pull/54210 if !chunking && Sys.iswindows() && ctx.stringtype !== PosLenString - finalize(ctx.buf) + if VERSION ≥ v"1.11" + finalize(ctx.buf.ref.mem) + else + finalize(ctx.buf) + end end # check if a temp file was generated for parsing if !chunking && ctx.tempfile !== nothing && ctx.stringtype !== PosLenString diff --git a/test/basics.jl b/test/basics.jl index 8a4c5a64..24e913e1 100644 --- a/test/basics.jl +++ b/test/basics.jl @@ -378,21 +378,8 @@ f = CSV.File(IOBuffer("a,b,c\n1,2,3\n\n")) f = CSV.File(IOBuffer("zip\n11111-1111\n"), dateformat = "y-m-dTH:M:S.s") @test (length(f), length(f.names)) == (1, 1) -# Supporting commands across multiple platforms cribbed from julia/test/spawn.jl -catcmd = `cat` -havebb = false -if Sys.iswindows() - busybox = download("https://frippery.org/files/busybox/busybox.exe", joinpath(tempdir(), "busybox.exe")) - havebb = try # use busybox-w32 on windows, if available - success(`$busybox`) - true - catch - false - end - if havebb - catcmd = `$busybox cat` - end -end +# `cat` isn't always available on Windows +catcmd = `$(Base.julia_cmd()) --eval "write(stdout, open(ARGS[1]))"` f = CSV.File(`$(catcmd) $(joinpath(dir, "test_basic.csv"))`) @test columntable(f) == columntable(CSV.File(joinpath(dir, "test_basic.csv")))