Skip to content

tmpname(parent) does not respect parent #35785

Closed
@nico202

Description

@nico202

Hello! I'm packaging julia 1.4.1 for guix, and this test is failing

@test dirname(t) == d

I can reproduce it with:

using Test
using Random

function run()
    @testset "tempname with parent" begin
        t = tempname()
        @test dirname(t) == tempdir()
        mktempdir() do d
            t = tempname(d)
            @test dirname(t) == d
        end
        @test_throws ArgumentError tempname(randstring())
    end
end
# tempdir() uses the first environment variable found in the ordered list TMPDIR, TMP, TEMP, and TEMPDIR. If none of these are found, the path "/tmp" is used.
# Let's check all those variables are currently empty
all_empty() = @test all(isnothing.(get.(Ref(ENV), ["TMPDIR", "TMP", "TEMP", "TEMPDIR"], nothing)))
all_empty()

# Check the test passes when no "TEMP" variable is set
@info "No env var"
run()

@info "TMPDIR var"
withenv("TMPDIR" => mktempdir()) do
    run()
end
all_empty()

Can anybody confirm the same happens with the official build?

Thanks, Nicolò

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions