1616
1717@testset " Runner tests" begin
1818 @testset " Installed packages by name in primary environment" begin
19- # Pkg.add
19+ # For speed avoid updating registry, we have a fresh one anyway
20+ Pkg. UPDATED_REGISTRY_THIS_SESSION[] = true
21+ # Pkg.add test
2022 Pkg. add(TEST_PKG. name)
2123 test_successful_testrun(() -> TestReports. test(TEST_PKG. name), TEST_PKG. name)
2224 Pkg. rm(TEST_PKG. name)
2325 @test_throws TestReports. PkgTestError TestReports. test(TEST_PKG. name)
24-
25- # Pkg.develop
26- pkgname = " PassingTests"
27- Pkg. develop(Pkg. PackageSpec(path= joinpath(@__DIR__, " test_packages" , pkgname)))
28- test_successful_testrun(() -> TestReports. test(pkgname), pkgname)
29- Pkg. rm(" PassingTests" )
3026 end
3127
3228 @testset " Activated projects - TestReports in stacked environment" begin
3329 @testset " by name" begin
3430 # The test run should not fail when passed the name of the project
3531 # that is activated and fail when its deactivated
36- test_active_package_expected_pass(" PassingTests" )
32+ temp_pkg_dir() do tmp
33+ pkg = " PassingTests"
34+ path = copy_test_package(tmp, pkg)
35+ Pkg. activate(path)
36+ test_successful_testrun(() -> TestReports. test(pkg), pkg)
37+ end
3738 @test_throws TestReports. PkgTestError TestReports. test(TEST_PKG. name)
3839 end
3940
5758
5859 @testset " Non-package error in runner" begin
5960 temp_pkg_dir() do tmp
60- pkgname = " PassingTests"
61- Pkg. develop(Pkg. PackageSpec(path= joinpath(@__DIR__, " test_packages " , pkgname )))
61+ pkg = " PassingTests"
62+ Pkg. develop(Pkg. PackageSpec(path= test_package_path(pkg )))
6263 # Pass non-existing argument to julia to make run command fail
63- @test_throws TestReports. PkgTestError TestReports. test(pkgname , julia_args= ` --doesnt-exist` )
64+ @test_throws TestReports. PkgTestError TestReports. test(pkg , julia_args= ` --doesnt-exist` )
6465 end
6566 end
6667end
6768
6869@testset " Test packages" begin
6970 # Errors
70- test_active_package_expected_fail (" FailedTest" )
71- test_active_package_expected_fail (" ErroredTest" )
72- test_active_package_expected_fail (" NoTestFile" )
71+ test_package_expected_fail (" FailedTest" )
72+ test_package_expected_fail (" ErroredTest" )
73+ test_package_expected_fail (" NoTestFile" )
7374
7475 # Various test dependencies
7576 test_pkgs = [
7677 " TestsWithDeps" ,
7778 " TestsWithTestDeps"
7879 ]
79- for pkg in test_pkgs
80- test_active_package_expected_pass(pkg)
81- end
80+ foreach(test_package_expected_pass, test_pkgs)
8281
8382 # Test file project file tests, 1.2 and above
8483 @static if VERSION >= v" 1.2.0"
8584 test_pkgs = [
8685 " TestsWithProjectFile" ,
8786 " TestsWithProjectFileWithTestDeps"
8887 ]
89- for pkg in test_pkgs
90- test_active_package_expected_pass(pkg)
91- end
88+ foreach(test_package_expected_pass, test_pkgs)
9289 end
9390
9491 # Test arguments
9592 temp_pkg_dir() do tmp
9693 pkg = " TestArguments"
97- copy_test_package(tmp, pkg)
98- Pkg. activate(joinpath(tmp, pkg))
94+ Pkg. develop(Pkg. PackageSpec(path= test_package_path(pkg)))
9995 test_successful_testrun(() -> TestReports. test(pkg; test_args= ` a b` , julia_args= ` --quiet --check-bounds=no` ), pkg)
10096 test_successful_testrun(() -> TestReports. test(pkg; test_args= [" a" , " b" ], julia_args= ` --quiet --check-bounds=no` ), pkg)
10197 end
@@ -107,27 +103,21 @@ end
107103 # Single package tests
108104 TestReports. test(TEST_PKG. name)
109105 @test isfile(joinpath(pwd()," testlog.xml" ))
110- TestReports. test(TEST_PKG. name; logfilename= " changedname.xml" )
111- @test isfile(joinpath(pwd()," changedname.xml" ))
112106 new_path = joinpath(pwd(), " NonExistentDir" )
113- TestReports. test(TEST_PKG. name; logfilename= " testlog .xml" , logfilepath= new_path)
114- @test isfile(joinpath(new_path," testlog .xml" ))
107+ TestReports. test(TEST_PKG. name; logfilename= " changedname .xml" , logfilepath= new_path)
108+ @test isfile(joinpath(new_path," changedname .xml" ))
115109 Pkg. rm(TEST_PKG. name)
116110
117111 # Multiple package test
118112 temp_pkg_dir() do tmp
119- copy_test_package(tmp, " PassingTests" )
120- Pkg. activate(tmp)
121- Pkg. develop(Pkg. PackageSpec(path= joinpath(tmp, " PassingTests" )))
113+ Pkg. develop(Pkg. PackageSpec(path= test_package_path(" PassingTests" )))
122114 Pkg. add(TEST_PKG. name)
123115 TestReports. test([TEST_PKG. name, " PassingTests" ])
124116 @test isfile(joinpath(pwd()," Example_testlog.xml" ))
125117 @test isfile(joinpath(pwd()," PassingTests_testlog.xml" ))
126118 TestReports. test([TEST_PKG. name, " PassingTests" ]; logfilename= [" testlog1.xml" , " testlog2.xml" ])
127119 @test isfile(joinpath(pwd()," testlog1.xml" ))
128120 @test isfile(joinpath(pwd()," testlog2.xml" ))
129- Pkg. rm(" PassingTests" )
130- Pkg. rm(TEST_PKG. name)
131121 end
132122
133123 # Errors
136126 @test_throws TypeError TestReports. test(TEST_PKG. name; logfilename= [" ThisShouldJustBeAString.xml" ])
137127
138128 # Tidy up
139- rm.(joinpath.(Ref(pwd()), [" testlog.xml" , " changedname.xml " , " Example_testlog.xml" , " PassingTests_testlog.xml" , " testlog1.xml" , " testlog2.xml" ]))
129+ rm.(joinpath.(Ref(pwd()), [" testlog.xml" , " Example_testlog.xml" , " PassingTests_testlog.xml" , " testlog1.xml" , " testlog2.xml" ]))
140130 rm(new_path, recursive= true )
141131end
142132
0 commit comments