16
16
17
17
@testset " Runner tests" begin
18
18
@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
20
22
Pkg. add (TEST_PKG. name)
21
23
test_successful_testrun (() -> TestReports. test (TEST_PKG. name), TEST_PKG. name)
22
24
Pkg. rm (TEST_PKG. name)
23
25
@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" )
30
26
end
31
27
32
28
@testset " Activated projects - TestReports in stacked environment" begin
33
29
@testset " by name" begin
34
30
# The test run should not fail when passed the name of the project
35
31
# 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
37
38
@test_throws TestReports. PkgTestError TestReports. test (TEST_PKG. name)
38
39
end
39
40
57
58
58
59
@testset " Non-package error in runner" begin
59
60
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 )))
62
63
# 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` )
64
65
end
65
66
end
66
67
end
67
68
68
69
@testset " Test packages" begin
69
70
# 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" )
73
74
74
75
# Various test dependencies
75
76
test_pkgs = [
76
77
" TestsWithDeps" ,
77
78
" TestsWithTestDeps"
78
79
]
79
- for pkg in test_pkgs
80
- test_active_package_expected_pass (pkg)
81
- end
80
+ foreach (test_package_expected_pass, test_pkgs)
82
81
83
82
# Test file project file tests, 1.2 and above
84
83
@static if VERSION >= v " 1.2.0"
85
84
test_pkgs = [
86
85
" TestsWithProjectFile" ,
87
86
" TestsWithProjectFileWithTestDeps"
88
87
]
89
- for pkg in test_pkgs
90
- test_active_package_expected_pass (pkg)
91
- end
88
+ foreach (test_package_expected_pass, test_pkgs)
92
89
end
93
90
94
91
# Test arguments
95
92
temp_pkg_dir () do tmp
96
93
pkg = " TestArguments"
97
- copy_test_package (tmp, pkg)
98
- Pkg. activate (joinpath (tmp, pkg))
94
+ Pkg. develop (Pkg. PackageSpec (path= test_package_path (pkg)))
99
95
test_successful_testrun (() -> TestReports. test (pkg; test_args= ` a b` , julia_args= ` --quiet --check-bounds=no` ), pkg)
100
96
test_successful_testrun (() -> TestReports. test (pkg; test_args= [" a" , " b" ], julia_args= ` --quiet --check-bounds=no` ), pkg)
101
97
end
@@ -107,27 +103,21 @@ end
107
103
# Single package tests
108
104
TestReports. test (TEST_PKG. name)
109
105
@test isfile (joinpath (pwd ()," testlog.xml" ))
110
- TestReports. test (TEST_PKG. name; logfilename= " changedname.xml" )
111
- @test isfile (joinpath (pwd ()," changedname.xml" ))
112
106
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" ))
115
109
Pkg. rm (TEST_PKG. name)
116
110
117
111
# Multiple package test
118
112
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" )))
122
114
Pkg. add (TEST_PKG. name)
123
115
TestReports. test ([TEST_PKG. name, " PassingTests" ])
124
116
@test isfile (joinpath (pwd ()," Example_testlog.xml" ))
125
117
@test isfile (joinpath (pwd ()," PassingTests_testlog.xml" ))
126
118
TestReports. test ([TEST_PKG. name, " PassingTests" ]; logfilename= [" testlog1.xml" , " testlog2.xml" ])
127
119
@test isfile (joinpath (pwd ()," testlog1.xml" ))
128
120
@test isfile (joinpath (pwd ()," testlog2.xml" ))
129
- Pkg. rm (" PassingTests" )
130
- Pkg. rm (TEST_PKG. name)
131
121
end
132
122
133
123
# Errors
136
126
@test_throws TypeError TestReports. test (TEST_PKG. name; logfilename= [" ThisShouldJustBeAString.xml" ])
137
127
138
128
# 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" ]))
140
130
rm (new_path, recursive= true )
141
131
end
142
132
0 commit comments