Skip to content
Draft
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
14 changes: 14 additions & 0 deletions src/SciMLBenchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ macro subprocess(ex, wait = true)
end
end

function manifest_julia_version(folder)
manifest_file = joinpath(folder, "Manifest.toml")
isfile(manifest_file) || return nothing
version_match = match(r"^julia_version\s*=\s*\"([^\"]+)\""m, read(manifest_file, String))
return isnothing(version_match) ? nothing : VersionNumber(only(version_match.captures))
end

function weave_file(folder, file, build_list = (:script, :github))
Weave.set_chunk_defaults!(:error => false)
target = joinpath(folder, file)
Expand All @@ -25,6 +32,13 @@ function weave_file(folder, file, build_list = (:script, :github))
@info("Instantiating", folder)
Pkg.activate(folder)
withenv("JULIA_PKG_PRECOMPILE_AUTO" => "0") do
manifest_version = manifest_julia_version(folder)
# Older Julia releases cannot resolve stdlibs pinned by a newer manifest.
if manifest_version === nothing ||
(VERSION.major, VERSION.minor) >=
(manifest_version.major, manifest_version.minor)
Pkg.resolve()
end
Pkg.instantiate()
end
Pkg.build()
Expand Down
23 changes: 23 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,29 @@ using SciMLBenchmarks, Test
include("explicit_imports.jl")
end

@testset "weave_file resolves stale manifests" begin
mktempdir() do folder
write(
joinpath(folder, "Project.toml"),
"""
[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
""",
)
write(
joinpath(folder, "Manifest.toml"),
"""
julia_version = "$(VERSION)"
manifest_format = "2.0"
project_hash = "0000000000000000000000000000000000000000"
""",
)

@test SciMLBenchmarks.weave_file(folder, "unused.jmd", ()) === nothing
@test occursin("[[deps.Dates]]", read(joinpath(folder, "Manifest.toml"), String))
end
end

@testset "weave_file" begin
benchmarks_dir = joinpath(dirname(@__DIR__), "benchmarks")
SciMLBenchmarks.weave_file(joinpath(benchmarks_dir, "Testing"), "test.jmd")
Expand Down
Loading