From 37edc96fc22c1a88ec4fb46ff8d1c111e8688839 Mon Sep 17 00:00:00 2001 From: Colin Caine Date: Tue, 30 Jan 2024 13:01:58 +0000 Subject: [PATCH] Reduce track-level runtests.jl output Inspired by #680 and #686 --- runtests.jl | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/runtests.jl b/runtests.jl index bfa9e851..4bce714b 100644 --- a/runtests.jl +++ b/runtests.jl @@ -9,32 +9,33 @@ get(ENV, "GITHUB_ACTIONS", "false") == "true" && global_logger(GitHubActionsLogg include("eachexercise.jl") -eachexercise(ARGS) do exercise, exercise_type, exercise_path, example_path - # Skip exercise tests if the Julia version doesn't meet the required version as specified in .meta/config.json - cfg = JSON.parsefile(joinpath(exercise_path, ".meta", "config.json")) - required_version_spec = Pkg.Types.semver_spec(get(cfg, "language_versions", "1.0")) - if VERSION ∉ required_version_spec - @info "$exercise requires Julia $required_version_spec, skipping tests." - println() - return - end - - # Create an anonymous module so that exercises are tested in separate scopes - m = Module() +@testset "exemplars" begin + eachexercise(ARGS) do exercise, exercise_type, exercise_path, example_path + @testset "$exercise" begin + # Skip exercise tests if the Julia version doesn't meet the required version as specified in .meta/config.json + cfg = JSON.parsefile(joinpath(exercise_path, ".meta", "config.json")) + required_version_spec = Pkg.Types.semver_spec(get(cfg, "language_versions", "1.0")) + if VERSION ∉ required_version_spec + @info "$exercise requires Julia $required_version_spec, skipping tests." + println() + return + end - # When testing the example solution, all tests must pass, even those that are marked as skipped or broken. - # The student will not be affected by this. - # Overwrite @test_skip and @test_broken with @test - @eval m using Test - @eval m $(Symbol("@test_skip")) = $(Symbol("@test")) - @eval m $(Symbol("@test_broken")) = $(Symbol("@test")) + # Create an anonymous module so that exercises are tested in separate scopes + m = Module() - # runtests.jl includes the solution by calling `include("slug.jl")` - # Our anonymous module doesn't have `include(s::String)` defined, - # so we define our own. - @eval m include(s) = Base.include($m, $example_path) - @info "[$(uppercase(exercise_type))] Testing $exercise" - Base.include(m, joinpath(exercise_path, "runtests.jl")) + # When testing the example solution, all tests must pass, even those that are marked as skipped or broken. + # So we overwrite @test_skip and @test_broken with @test to enable those tests. + @eval m using Test + @eval m $(Symbol("@test_skip")) = $(Symbol("@test")) + @eval m $(Symbol("@test_broken")) = $(Symbol("@test")) - println() # to make the output more readable + # runtests.jl includes the solution by calling `include("slug.jl")` + # Our anonymous module doesn't have `include(s::String)` defined, + # so we define our own. + @eval m include(s) = Base.include($m, $example_path) + @info "[$(uppercase(exercise_type))] Testing $exercise" + Base.include(m, joinpath(exercise_path, "runtests.jl")) + end + end end