diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79bc32d..2b84ee6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,9 +15,8 @@ jobs: fail-fast: false matrix: version: - - '1.0' - - '1.6' - - '1' + - '1.6' # LTS / Oldest supported version + - '1' # Latest release - 'nightly' os: - ubuntu-latest diff --git a/Project.toml b/Project.toml index 60db2d0..b3afb59 100644 --- a/Project.toml +++ b/Project.toml @@ -11,7 +11,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] EzXML = "1" -julia = "1" +julia = "1.6" [extras] ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf" diff --git a/src/TestReports.jl b/src/TestReports.jl index 1c727fe..3f09c04 100644 --- a/src/TestReports.jl +++ b/src/TestReports.jl @@ -8,8 +8,8 @@ using Test using Pkg: PackageSpec using Pkg.Types: Context, ensure_resolved, is_project_uuid -using Pkg.Operations: manifest_info, manifest_resolve!, project_deps_resolve!, - project_rel_path, project_resolve! +using Pkg.Operations: gen_target_project, manifest_info, manifest_resolve!, + project_deps_resolve!, project_rel_path, project_resolve!, sandbox, source_path using Test: AbstractTestSet, DefaultTestSet, Result, Pass, Fail, Error, Broken, get_testset, get_testset_depth, scrub_backtrace @@ -17,19 +17,8 @@ using Test: AbstractTestSet, DefaultTestSet, Result, Pass, Fail, Error, Broken, import Test: finish, record # Version specific imports -@static if VERSION >= v"1.4.0" - using Pkg.Operations: gen_target_project -else - using Pkg.Operations: with_dependencies_loadable_at_toplevel -end -@static if VERSION >= v"1.2.0" - using Pkg.Operations: sandbox, source_path - @static if VERSION < v"1.7.0" - using Pkg.Operations: update_package_test! - end -else - using Pkg.Operations: find_installed - using Pkg.Types: SHA1 +@static if VERSION < v"1.7.0" + using Pkg.Operations: update_package_test! end export ReportingTestSet, any_problems, report, recordproperty @@ -45,7 +34,6 @@ const TESTREPORTS_UUID = let Base.UUID(toml["uuid"]) end -include("v1_compat.jl") include("./testsets.jl") include("to_xml.jl") include("compat_check.jl") diff --git a/src/compat_check.jl b/src/compat_check.jl index 93a7f10..fbd2dc4 100644 --- a/src/compat_check.jl +++ b/src/compat_check.jl @@ -76,11 +76,9 @@ function getdeps(manifest) @static if VERSION >= v"1.6.2" # Manifest is a struct return manifest.deps - elseif VERSION >= v"1.1.0" + else # Manifest is a dict of UUID to PackageEntry return manifest - else - return manifest["deps"] end end @@ -141,59 +139,32 @@ not a stdlib or Julia. """ function get_dep_entries end -@static if VERSION >= v"1.1" - function get_dep_entries() - # Get names - testreport_proj = Pkg.Types.EnvCache(joinpath(dirname(@__DIR__), "Project.toml")).project - dep_names_to_check = intersect(keys(testreport_proj.deps), keys(testreport_proj.compat)) # Ignores julia and stdlibs - - # Get PackageEntries from activte Manifest.toml or build from TestReports Project.toml - deps_to_check = Pkg.Types.PackageEntry[] - active_env = Pkg.Types.EnvCache(Base.active_project()) - for dep in dep_names_to_check - if haskey(getdeps(active_env.manifest), testreport_proj.deps[dep]) - push!(deps_to_check, getdeps(active_env.manifest)[testreport_proj.deps[dep]]) - else - @static if VERSION >= v"1.7.0" - version_number = VersionNumber(testreport_proj.compat[dep].str) - else - version_number = VersionNumber(testreport_proj.compat[dep]) - end - pkg_entry = Pkg.Types.PackageEntry( - name=dep, - other=Dict("uuid" => testreport_proj.deps[dep]), - version=version_number - ) - push!(deps_to_check, pkg_entry) - end - end - return deps_to_check - end -else - function get_dep_entries() - # Get names - testreport_proj = Pkg.Types.EnvCache(joinpath(dirname(@__DIR__), "Project.toml")).project - dep_names_to_check = intersect(keys(getdeps(testreport_proj)), keys(getcompat(testreport_proj))) # Ignores julia and stdlibs - - # Get PackageEntries from activte Manifest.toml or build from TestReports Project.toml - deps_to_check = Dict[] - active_env = Pkg.Types.EnvCache(Base.active_project()) - for dep in dep_names_to_check - if haskey(active_env.manifest, dep) - dep_to_check = active_env.manifest[dep][1] # why is this a vector? - dep_to_check["name"] = dep - push!(deps_to_check, dep_to_check) +function get_dep_entries() + # Get names + testreport_proj = Pkg.Types.EnvCache(joinpath(dirname(@__DIR__), "Project.toml")).project + dep_names_to_check = intersect(keys(testreport_proj.deps), keys(testreport_proj.compat)) # Ignores julia and stdlibs + + # Get PackageEntries from activte Manifest.toml or build from TestReports Project.toml + deps_to_check = Pkg.Types.PackageEntry[] + active_env = Pkg.Types.EnvCache(Base.active_project()) + for dep in dep_names_to_check + if haskey(getdeps(active_env.manifest), testreport_proj.deps[dep]) + push!(deps_to_check, getdeps(active_env.manifest)[testreport_proj.deps[dep]]) + else + @static if VERSION >= v"1.7.0" + version_number = VersionNumber(testreport_proj.compat[dep].str) else - pkg_entry = Dict( - "name" => dep, - "uuid" => testreport_proj["deps"][dep], - "version" => VersionNumber(testreport_proj["compat"][dep]) - ) - push!(deps_to_check, pkg_entry) + version_number = VersionNumber(testreport_proj.compat[dep]) end + pkg_entry = Pkg.Types.PackageEntry( + name=dep, + other=Dict("uuid" => testreport_proj.deps[dep]), + version=version_number + ) + push!(deps_to_check, pkg_entry) end - return deps_to_check end + return deps_to_check end """ diff --git a/src/runner.jl b/src/runner.jl index 224c937..df2deee 100644 --- a/src/runner.jl +++ b/src/runner.jl @@ -150,12 +150,6 @@ Returns `Cmd` which will run the runner code in a new Julia instance. See also: [`gen_runner_code`](@ref) """ function gen_command(runner_code, julia_args, coverage) - @static if VERSION >= v"1.5.0" - threads_cmd = `--threads=$(Threads.nthreads())` - else - threads_cmd = `` - end - cmd = ``` $(Base.julia_cmd()) --code-coverage=$(coverage ? "user" : "none") @@ -166,7 +160,7 @@ function gen_command(runner_code, julia_args, coverage) --inline=$(Bool(Base.JLOptions().can_inline) ? "yes" : "no") --startup-file=$(Base.JLOptions().startupfile == 1 ? "yes" : "no") --track-allocation=$(("none", "user", "all")[Base.JLOptions().malloc_log + 1]) - $threads_cmd + --threads=$(Threads.nthreads()) $(julia_args) --eval $(runner_code) ``` @@ -185,10 +179,10 @@ is of type `Pkg.Types.Context`. For earlier versions, they are of type `Pkg.Types.EnvCache`. """ function isinstalled!(ctx::Context, pkgspec::Pkg.Types.PackageSpec) - @static if v"1.4.0" <= VERSION < v"1.7.0" - var = ctx - else + @static if VERSION >= v"1.7.0" var = ctx.env + else + var = ctx end @static if VERSION >= v"1.7.0" manifest_var = ctx.env.manifest @@ -234,7 +228,7 @@ function gettestfilepath(ctx::Context, pkgspec::Pkg.Types.PackageSpec) end end pkgfilepath = source_path(ctx.env.project_file, pkgspec, ctx.julia_version) - elseif VERSION >= v"1.4.0" + else if is_project_uuid(ctx, pkgspec.uuid) pkgspec.path = dirname(ctx.env.project_file) pkgspec.version = ctx.env.pkg.version @@ -243,51 +237,6 @@ function gettestfilepath(ctx::Context, pkgspec::Pkg.Types.PackageSpec) pkgspec.path = project_rel_path(ctx, source_path(ctx, pkgspec)) end pkgfilepath = source_path(ctx, pkgspec) - elseif VERSION >= v"1.2.0" - pkgspec.special_action = Pkg.Types.PKGSPEC_TESTED - if is_project_uuid(ctx.env, pkgspec.uuid) - pkgspec.path = dirname(ctx.env.project_file) - pkgspec.version = ctx.env.pkg.version - else - update_package_test!(pkgspec, manifest_info(ctx.env, pkgspec.uuid)) - pkgspec.path = joinpath(project_rel_path(ctx, source_path(pkgspec))) - end - pkgfilepath = project_rel_path(ctx, source_path(pkgspec)) - elseif VERSION >= v"1.1.0" - pkgspec.special_action = Pkg.Types.PKGSPEC_TESTED - if is_project_uuid(ctx.env, pkgspec.uuid) - pkgspec.version = ctx.env.pkg.version - pkgfilepath = dirname(ctx.env.project_file) - else - entry = manifest_info(ctx.env, pkg.uuid) - if entry.repo.tree_sha !== nothing - pkgfilepath = find_installed(pkgspec.name, pkgspec.uuid, entry.repo.tree_sha) - elseif entry.path !== nothing - pkgfilepath = project_rel_path(ctx, entry.path) - elseif pkgspec.uuid in keys(ctx.stdlibs) - pkgfilepath = Pkg.Types.stdlib_path(pkgspec.name) - else - throw(PkgTestError("Could not find either `git-tree-sha1` or `path` for package $(pkgspec.name)")) - end - end - else - pkgspec.special_action = Pkg.Types.PKGSPEC_TESTED - if is_project_uuid(ctx.env, pkgspec.uuid) - pkgspec.version = ctx.env.pkg.version - pkgfilepath = dirname(ctx.env.project_file) - else - info = manifest_info(ctx.env, pkgspec.uuid) - if haskey(info, "git-tree-sha1") - pkgfilepath = find_installed(pkgspec.name, pkgspec.uuid, SHA1(info["git-tree-sha1"])) - elseif haskey(info, "path") - pkgfilepath = project_rel_path(ctx, info["path"]) - elseif pkgspec.uuid in keys(ctx.stdlibs) - pkgfilepath = Pkg.Types.stdlib_path(pkgspec.name) - else - throw(PkgTestError("Could not find either `git-tree-sha1` or `path` for package $(pkgspec.name)")) - end - end - pkgspec.path = pkgfilepath end testfilepath = joinpath(pkgfilepath, "test", "runtests.jl") return testfilepath @@ -376,42 +325,31 @@ function test!(pkg::AbstractString, cmd = gen_command(runner_code, julia_args, coverage) test_folder_has_project_file = has_test_project_file(testfilepath) - if VERSION >= v"1.4.0" || (VERSION >= v"1.2.0" && test_folder_has_project_file) - # Operations.sandbox() has different arguments between versions - sandbox_args = (ctx, - pkgspec, - pkgspec.path, - joinpath(pkgspec.path, "test")) - if VERSION >= v"1.8.0" - test_project_override = test_folder_has_project_file ? - nothing : - gen_target_project(ctx, pkgspec, pkgspec.path::String, "test") - sandbox_args = (sandbox_args..., test_project_override) - elseif VERSION >= v"1.7.0" - test_project_override = test_folder_has_project_file ? - nothing : - gen_target_project(ctx.env, ctx.registries, pkgspec, pkgspec.path, "test") - sandbox_args = (sandbox_args..., test_project_override) - elseif VERSION >= v"1.4.0" - test_project_override = test_folder_has_project_file ? - nothing : - gen_target_project(ctx, pkgspec, pkgspec.path, "test") - sandbox_args = (sandbox_args..., test_project_override) - end - - sandbox(sandbox_args...) do - flush(stdout) - runtests!(errs, pkg, cmd, logfilename) - end + # Operations.sandbox() has different arguments between versions + sandbox_args = (ctx, + pkgspec, + pkgspec.path, + joinpath(pkgspec.path, "test")) + if VERSION >= v"1.8.0" + test_project_override = test_folder_has_project_file ? + nothing : + gen_target_project(ctx, pkgspec, pkgspec.path::String, "test") + sandbox_args = (sandbox_args..., test_project_override) + elseif VERSION >= v"1.7.0" + test_project_override = test_folder_has_project_file ? + nothing : + gen_target_project(ctx.env, ctx.registries, pkgspec, pkgspec.path, "test") + sandbox_args = (sandbox_args..., test_project_override) else - with_dependencies_loadable_at_toplevel(ctx, pkgspec; might_need_to_resolve=true) do localctx - Pkg.activate(localctx.env.project_file) - try - runtests!(errs, pkg, cmd, logfilename) - finally - Pkg.activate(ctx.env.project_file) - end - end + test_project_override = test_folder_has_project_file ? + nothing : + gen_target_project(ctx, pkgspec, pkgspec.path, "test") + sandbox_args = (sandbox_args..., test_project_override) + end + + sandbox(sandbox_args...) do + flush(stdout) + runtests!(errs, pkg, cmd, logfilename) end end end diff --git a/src/v1_compat.jl b/src/v1_compat.jl deleted file mode 100644 index 8f3b39c..0000000 --- a/src/v1_compat.jl +++ /dev/null @@ -1,9 +0,0 @@ -@static if VERSION < v"1.1.0" - """ - isnothing(x) - - Return `true` if `x === nothing`, and return `false` if not. - """ - isnothing(::Any) = false - isnothing(::Nothing) = true -end \ No newline at end of file diff --git a/test/reportgeneration.jl b/test/reportgeneration.jl index fe4a8f5..80af8fc 100644 --- a/test/reportgeneration.jl +++ b/test/reportgeneration.jl @@ -87,14 +87,12 @@ end ] foreach(test_package_expected_pass, test_pkgs) - # Test file project file tests, 1.2 and above - @static if VERSION >= v"1.2.0" - test_pkgs = [ - "TestsWithProjectFile", - "TestsWithProjectFileWithTestDeps" - ] - foreach(test_package_expected_pass, test_pkgs) - end + # Test file project file tests + test_pkgs = [ + "TestsWithProjectFile", + "TestsWithProjectFileWithTestDeps" + ] + foreach(test_package_expected_pass, test_pkgs) # Test arguments temp_pkg_dir() do tmp diff --git a/test/runnerinternals.jl b/test/runnerinternals.jl index fea505c..d1f35c8 100644 --- a/test/runnerinternals.jl +++ b/test/runnerinternals.jl @@ -2,29 +2,6 @@ using Pkg using Test using TestReports -if VERSION < v"1.2.0" - @testset "gettestfilepath - V1.0.5" begin - # Stdlibs are not tested by other functions for V1.0.5 - stdlibname = "Dates" - ctx = Pkg.Types.Context() - pkg = Pkg.PackageSpec(stdlibname) - TestReports.isinstalled!(ctx, pkg) - delete!(ctx.env.manifest[stdlibname][1], "path") # Remove path to force stdlib check - testfilepath = joinpath(abspath(joinpath(dirname(Base.find_package(stdlibname)), "..")), "test", "runtests.jl") - @test TestReports.gettestfilepath(ctx, pkg) == testfilepath - - # PkgTestError when PkgSpec has missing info when finding path - V1.0.5 only - pkgname = "PassingTests" - Pkg.develop(Pkg.PackageSpec(path=joinpath(@__DIR__, "test_packages", pkgname))) - ctx = Pkg.Types.Context() - pkg = Pkg.PackageSpec(pkgname) - TestReports.isinstalled!(ctx, pkg) - delete!(ctx.env.manifest["PassingTests"][1], "path") - @test_throws TestReports.PkgTestError TestReports.gettestfilepath(ctx, pkg) - Pkg.rm(Pkg.PackageSpec(path=joinpath(@__DIR__, "test_packages", pkgname))) - end -end - @testset "showerror" begin @test_throws TestReports.PkgTestError throw(TestReports.PkgTestError("Test")) @test sprint(showerror, TestReports.PkgTestError("Error text"), "") == "Error text" @@ -54,15 +31,13 @@ end test_package_expected_fail("OldTestReportsInTarget") test_package_expected_fail("OldTestReportsInDeps") test_package_expected_fail("OldDepInTarget") - if VERSION >= v"1.2.0" - test_package_expected_fail("OldTestReportsInTestDeps") - test_package_expected_fail("OldDepInTestDeps") - if VERSION >= v"1.7.0" - test_package_expected_fail("OldTestReportsInTestManifest_1_7") # new manifest format - test_package_expected_fail("OldDepInTestManifest_1_7") # new manifest format - else - test_package_expected_fail("OldTestReportsInTestManifest") - test_package_expected_fail("OldDepInTestManifest") - end + test_package_expected_fail("OldTestReportsInTestDeps") + test_package_expected_fail("OldDepInTestDeps") + if VERSION >= v"1.7.0" + test_package_expected_fail("OldTestReportsInTestManifest_1_7") # new manifest format + test_package_expected_fail("OldDepInTestManifest_1_7") # new manifest format + else + test_package_expected_fail("OldTestReportsInTestManifest") + test_package_expected_fail("OldDepInTestManifest") end -end \ No newline at end of file +end diff --git a/test/to_xml.jl b/test/to_xml.jl index dae07cb..00192fb 100644 --- a/test/to_xml.jl +++ b/test/to_xml.jl @@ -25,11 +25,7 @@ struct CustomException <: Exception end end err = ts.results[1].result _, type, _ = TestReports.get_error_info(err) - if VERSION < v"1.2" - @test type == "ErrorException" - else - @test type == "ProcessFailedException" - end + @test type == "ProcessFailedException" # Custom exception ts = @testset ReportingTestSet begin @@ -39,4 +35,4 @@ struct CustomException <: Exception end _, type, _ = TestReports.get_error_info(err) @test type == "CustomException" end -end \ No newline at end of file +end