Skip to content
Merged
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
24 changes: 15 additions & 9 deletions test/manifests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@ using ..Utils
# used with the reference manifests in `test/manifest/formats`
# ensures the manifests are valid and restored after test
function reference_manifest_isolated_test(f, dir::String; v1::Bool=false)
env_dir = joinpath(@__DIR__, "manifest", "formats", dir)
env_manifest = joinpath(env_dir, "Manifest.toml")
env_project = joinpath(env_dir, "Project.toml")
cp(env_manifest, string(env_manifest, "_backup"))
cp(env_project, string(env_project, "_backup"))
source_env_dir = joinpath(@__DIR__, "manifest", "formats", dir)
source_env_manifest = joinpath(source_env_dir, "Manifest.toml")
source_env_project = joinpath(source_env_dir, "Project.toml")

# Create a temporary directory for the test files
temp_base_dir = mktempdir()
try
# Copy entire directory structure to preserve paths that tests expect
env_dir = joinpath(temp_base_dir, dir)
cp(source_env_dir, env_dir)

env_manifest = joinpath(env_dir, "Manifest.toml")
env_project = joinpath(env_dir, "Project.toml")

isfile(env_manifest) || error("Reference manifest is missing")
if Base.is_v1_format_manifest(Base.parsed_toml(env_manifest)) == !v1
error("Reference manifest file at $(env_manifest) is invalid")
Expand All @@ -21,10 +29,8 @@ function reference_manifest_isolated_test(f, dir::String; v1::Bool=false)
f(env_dir, env_manifest)
end
finally
cp(string(env_manifest, "_backup"), env_manifest, force = true)
rm(string(env_manifest, "_backup"))
cp(string(env_project, "_backup"), env_project, force = true)
rm(string(env_project, "_backup"))
# Clean up temporary directory
rm(temp_base_dir, recursive=true)
end
end

Expand Down