Skip to content

Commit

Permalink
Create temporary project with necessary modules
Browse files Browse the repository at this point in the history
  • Loading branch information
lkastner committed Apr 9, 2024
1 parent 127f46e commit db8ff73
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions test/utils/Banners/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
function run_repl_code(code::String)
function create_test_prog()
td = mktempdir()
oscprojdir = dirname(Base.identify_package_env("Oscar")[2])
cp(joinpath(oscprojdir,"Manifest.toml"),joinpath(td,"Manifest.toml"))
cp(joinpath(Oscar.oscardir,"Project.toml"),joinpath(td,"Project.toml"))
return td
end


function run_repl_code(code::String, proj::String)
bin = Base.julia_cmd()[1]
proj = dirname(Base.active_project())
# proj = dirname(Base.active_project())
opts = ["--project=$proj", "-i", "-e", "$code; exit();"]
cmd = addenv(Cmd(`$bin $opts`, ignorestatus=true), "JULIA_LOAD_PATH"=>join(LOAD_PATH, ":"))
outs = IOBuffer()
Expand All @@ -13,22 +22,24 @@ end

if VERSION>=v"1.9"
@testset "Banners" begin
oscar_banner, err = run_repl_code("using Oscar")
proj = create_test_prog()
run_repl_code("import Pkg; Pkg.up();", proj)
oscar_banner, err = run_repl_code("using Oscar", proj)
path = joinpath(Oscar.oscardir, "test/utils/Banners")
res1 = @test oscar_banner == load(joinpath(path, "oscar_banner.txt")) broken=VERSION>=v"1.11.0-DEV"
if res1 isa Test.Fail
println("OB")
println(oscar_banner)
println(err)
end
chain_banner, err = run_repl_code("using Oscar; using Polymake;")
chain_banner, err = run_repl_code("using Oscar; using Polymake;", proj)
res2 = @test chain_banner == load(joinpath(path, "oscar_banner.txt")) broken=VERSION>=v"1.11.0-DEV"
if res2 isa Test.Fail
println("CB")
println(oscar_banner)
println(err)
end
polymake_banner, err = run_repl_code("using Polymake")
polymake_banner, err = run_repl_code("using Polymake", proj)
res3 = @test polymake_banner == load(joinpath(path, "polymake_banner.txt")) broken=VERSION>=v"1.11.0-DEV"
if res3 isa Test.Fail
println("PB")
Expand All @@ -45,7 +56,7 @@ Pkg.develop(path="$project_path");
Pkg.develop(path="$testmod_path");
using BannerTestMod;
"""
testmod_banner, err = run_repl_code(module_test)
testmod_banner, err = run_repl_code(module_test, proj)
res4 = @test strip(testmod_banner) == "" broken=VERSION>=v"1.11.0-DEV"
if res4 isa Test.Fail
println("TB")
Expand Down

0 comments on commit db8ff73

Please sign in to comment.