Skip to content

Commit 7199602

Browse files
committed
Merge pull request #15263 from JuliaLang/tk/cleantests
Clean up some tests that are a bit noisier than they should be
2 parents f40d0db + d70f318 commit 7199602

File tree

6 files changed

+69
-102
lines changed

6 files changed

+69
-102
lines changed

test/core.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -3750,7 +3750,7 @@ end
37503750
module I13229
37513751
using Base.Test
37523752
global z = 0
3753-
@time @profile for i = 1:5
3753+
@timed @profile for i = 1:5
37543754
function f(x)
37553755
return x + i
37563756
end

test/examples.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ include(joinpath(dir, "queens.jl"))
4545
end
4646

4747
dc_path = joinpath(dir, "dictchannel.jl")
48-
include(dc_path)
48+
myid() == 1 || include(dc_path)
4949

5050
# Run the remote on pid 1, since runtests may terminate workers
5151
# at any time depending on memory usage

test/libgit2-online.jl

+11-27
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,17 @@
11
# This file is a part of Julia. License is MIT: http://julialang.org/license
22

3-
@testset "libgit2-online" begin
4-
5-
#########
6-
# Setup #
7-
#########
8-
9-
function temp_dir(fn::Function, remove_tmp_dir::Bool=true)
10-
tmpdir = joinpath(tempdir(),randstring())
11-
@test !isdir(tmpdir)
12-
try
13-
mkdir(tmpdir)
14-
@test isdir(tmpdir)
15-
fn(tmpdir)
16-
finally
17-
remove_tmp_dir && rm(tmpdir, recursive=true)
18-
end
19-
end
3+
#@testset "libgit2-online" begin
204

215
#########
226
# TESTS #
237
#########
248
# init & clone
25-
temp_dir() do dir
9+
mktempdir() do dir
2610
repo_url = "github.com/JuliaLang/Example.jl"
2711
https_prefix = "https://"
2812
ssh_prefix = "git@"
29-
@testset "Cloning repository" begin
30-
@testset "with 'https' protocol" begin
13+
#@testset "Cloning repository" begin
14+
#@testset "with 'https' protocol" begin
3115
repo_path = joinpath(dir, "Example1")
3216
repo = LibGit2.clone(https_prefix*repo_url, repo_path)
3317
try
@@ -36,24 +20,24 @@ temp_dir() do dir
3620
finally
3721
finalize(repo)
3822
end
39-
end
40-
@testset "with incorrect url" begin
23+
#end
24+
#@testset "with incorrect url" begin
4125
repo_path = joinpath(dir, "Example2")
4226
# credential are required because github try authenticate on uknown repo
4327
x = Nullable(LibGit2.UserPasswordCredentials("X","X"))
4428
@test_throws LibGit2.Error.GitError LibGit2.clone(https_prefix*repo_url*randstring(10), repo_path, payload=x)
45-
end
29+
#end
4630

4731
try
48-
@testset "with 'ssh' protocol (by default is not supported)" begin
32+
#@testset "with 'ssh' protocol (by default is not supported)" begin
4933
repo_path = joinpath(dir, "Example3")
5034
@test_throws LibGit2.Error.GitError LibGit2.clone(ssh_prefix*repo_url, repo_path)
51-
end
35+
#end
5236
catch ex
5337
# but we cloned succesfully, so check that repo was created
5438
ex.fail == 1 && @test isdir(joinpath(path, ".git"))
5539
end
56-
end
40+
#end
5741
end
5842

59-
end
43+
#end

test/libgit2.jl

+50-67
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,19 @@
11
# This file is a part of Julia. License is MIT: http://julialang.org/license
22

3-
@testset "libgit2" begin
3+
#@testset "libgit2" begin
44

55
const LIBGIT2_VER = v"0.23.0"
66

7-
#########
8-
# Setup #
9-
#########
10-
11-
function temp_dir(fn::Function, remove_tmp_dir::Bool=true)
12-
tmpdir = joinpath(tempdir(),randstring())
13-
@test !isdir(tmpdir)
14-
try
15-
mkdir(tmpdir)
16-
@test isdir(tmpdir)
17-
fn(tmpdir)
18-
finally
19-
remove_tmp_dir && rm(tmpdir, recursive=true)
20-
end
21-
end
22-
23-
247
#########
258
# TESTS #
269
#########
2710

28-
@testset "Check library verison" begin
11+
#@testset "Check library verison" begin
2912
v = LibGit2.version()
3013
@test v.major == LIBGIT2_VER.major && v.minor >= LIBGIT2_VER.minor
31-
end
14+
#end
3215

33-
@testset "OID" begin
16+
#@testset "OID" begin
3417
z = LibGit2.Oid()
3518
@test LibGit2.iszero(z)
3619
@test z == zero(LibGit2.Oid)
@@ -41,9 +24,9 @@ end
4124
@test z == LibGit2.Oid(pointer(rr))
4225
for i in 11:length(rr); rr[i] = 0; end
4326
@test LibGit2.Oid(rr) == LibGit2.Oid(rs[1:20])
44-
end
27+
#end
4528

46-
@testset "StrArrayStruct" begin
29+
#@testset "StrArrayStruct" begin
4730
p1 = "XXX"
4831
p2 = "YYY"
4932
sa1 = LibGit2.StrArrayStruct(p1)
@@ -67,19 +50,19 @@ end
6750
finally
6851
finalize(sa2)
6952
end
70-
end
53+
#end
7154

72-
@testset "Signature" begin
55+
#@testset "Signature" begin
7356
sig = LibGit2.Signature("AAA", "[email protected]", round(time(), 0), 0)
7457
git_sig = convert(LibGit2.GitSignature, sig)
7558
sig2 = LibGit2.Signature(git_sig)
7659
finalize(git_sig)
7760
@test sig.name == sig2.name
7861
@test sig.email == sig2.email
7962
@test sig.time == sig2.time
80-
end
63+
#end
8164

82-
temp_dir() do dir
65+
mktempdir() do dir
8366

8467
# test parameters
8568
repo_url = "https://github.com/JuliaLang/Example.jl"
@@ -97,7 +80,7 @@ temp_dir() do dir
9780
tag1 = "tag1"
9881
tag2 = "tag2"
9982

100-
@testset "Configuration" begin
83+
#@testset "Configuration" begin
10184
cfg = LibGit2.GitConfig(joinpath(dir, config_file), LibGit2.Consts.CONFIG_LEVEL_APP)
10285
try
10386
@test_throws LibGit2.Error.GitError LibGit2.get(AbstractString, cfg, "tmp.str")
@@ -115,10 +98,10 @@ temp_dir() do dir
11598
finally
11699
finalize(cfg)
117100
end
118-
end
101+
#end
119102

120-
@testset "Initializing repository" begin
121-
@testset "with remote branch" begin
103+
#@testset "Initializing repository" begin
104+
#@testset "with remote branch" begin
122105
repo = LibGit2.init(cache_repo)
123106
try
124107
@test isdir(cache_repo)
@@ -138,9 +121,9 @@ temp_dir() do dir
138121
finally
139122
finalize(repo)
140123
end
141-
end
124+
#end
142125

143-
@testset "bare" begin
126+
#@testset "bare" begin
144127
path = joinpath(dir, "Example.Bare")
145128
repo = LibGit2.init(path, true)
146129
try
@@ -149,12 +132,12 @@ temp_dir() do dir
149132
finally
150133
finalize(repo)
151134
end
152-
end
153-
end
135+
#end
136+
#end
154137

155-
@testset "Cloning repository" begin
138+
#@testset "Cloning repository" begin
156139

157-
@testset "bare" begin
140+
#@testset "bare" begin
158141
repo_path = joinpath(dir, "Example.Bare1")
159142
repo = LibGit2.clone(cache_repo, repo_path, isbare = true)
160143
try
@@ -163,8 +146,8 @@ temp_dir() do dir
163146
finally
164147
finalize(repo)
165148
end
166-
end
167-
@testset "bare with remote callback" begin
149+
#end
150+
#@testset "bare with remote callback" begin
168151
repo_path = joinpath(dir, "Example.Bare2")
169152
repo = LibGit2.clone(cache_repo, repo_path, isbare = true, remote_cb = LibGit2.mirror_cb())
170153
try
@@ -179,21 +162,21 @@ temp_dir() do dir
179162
finally
180163
finalize(repo)
181164
end
182-
end
183-
@testset "normal" begin
165+
#end
166+
#@testset "normal" begin
184167
repo = LibGit2.clone(cache_repo, test_repo, remote_cb = LibGit2.mirror_cb())
185168
try
186169
@test isdir(test_repo)
187170
@test isdir(joinpath(test_repo, ".git"))
188171
finally
189172
finalize(repo)
190173
end
191-
end
192-
end
174+
#end
175+
#end
193176

194-
@testset "Update cache repository" begin
177+
#@testset "Update cache repository" begin
195178

196-
@testset "with commits" begin
179+
#@testset "with commits" begin
197180
repo = LibGit2.GitRepo(cache_repo)
198181
repo_file = open(joinpath(cache_repo,test_file), "a")
199182
try
@@ -239,9 +222,9 @@ temp_dir() do dir
239222
finalize(repo)
240223
close(repo_file)
241224
end
242-
end
225+
#end
243226

244-
@testset "with branch" begin
227+
#@testset "with branch" begin
245228
repo = LibGit2.GitRepo(cache_repo)
246229
try
247230
brnch = LibGit2.branch(repo)
@@ -255,9 +238,9 @@ temp_dir() do dir
255238
finally
256239
finalize(repo)
257240
end
258-
end
241+
#end
259242

260-
@testset "with default configuration" begin
243+
#@testset "with default configuration" begin
261244
repo = LibGit2.GitRepo(cache_repo)
262245
try
263246
try
@@ -277,10 +260,10 @@ temp_dir() do dir
277260
finally
278261
finalize(repo)
279262
end
280-
end
263+
#end
281264

282265

283-
@testset "with tags" begin
266+
#@testset "with tags" begin
284267
repo = LibGit2.GitRepo(cache_repo)
285268
try
286269
tags = LibGit2.tag_list(repo)
@@ -306,10 +289,10 @@ temp_dir() do dir
306289
finally
307290
finalize(repo)
308291
end
309-
end
310-
end
292+
#end
293+
#end
311294

312-
@testset "Fetch from cache repository" begin
295+
#@testset "Fetch from cache repository" begin
313296
repo = LibGit2.GitRepo(test_repo)
314297
try
315298
# fetch changes
@@ -326,14 +309,14 @@ temp_dir() do dir
326309
finally
327310
finalize(repo)
328311
end
329-
end
312+
#end
330313

331-
@testset "Examine test repository" begin
332-
@testset "files" begin
314+
#@testset "Examine test repository" begin
315+
#@testset "files" begin
333316
@test readstring(joinpath(test_repo, test_file)) == readstring(joinpath(cache_repo, test_file))
334-
end
317+
#end
335318

336-
@testset "tags & branches" begin
319+
#@testset "tags & branches" begin
337320
repo = LibGit2.GitRepo(test_repo)
338321
try
339322
# all tag in place
@@ -348,9 +331,9 @@ temp_dir() do dir
348331
finally
349332
finalize(repo)
350333
end
351-
end
334+
#end
352335

353-
@testset "commits with revwalk" begin
336+
#@testset "commits with revwalk" begin
354337
repo = LibGit2.GitRepo(test_repo)
355338
cache = LibGit2.GitRepo(cache_repo)
356339
try
@@ -365,17 +348,17 @@ temp_dir() do dir
365348
cache_oids = LibGit2.with(LibGit2.GitRevWalker(cache)) do walker
366349
LibGit2.map((oid,repo)->string(oid), walker, by = LibGit2.Consts.SORT_TIME)
367350
end
368-
@testset for i in eachindex(oids)
351+
for i in eachindex(oids)
369352
@test cache_oids[i] == test_oids[i]
370353
end
371354
finally
372355
finalize(repo)
373356
finalize(cache)
374357
end
375-
end
376-
end
358+
#end
359+
#end
377360

378-
@testset "Transact test repository" begin
361+
#@testset "Transact test repository" begin
379362
repo = LibGit2.GitRepo(test_repo)
380363
try
381364
cp(joinpath(test_repo, test_file), joinpath(test_repo, "CCC"))
@@ -394,8 +377,8 @@ temp_dir() do dir
394377
finally
395378
finalize(repo)
396379
end
397-
end
380+
#end
398381

399382
end
400383

401-
end
384+
#end

test/ranges.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -563,14 +563,14 @@ end
563563

564564
# stringmime/writemime should display the range or linspace nicely
565565
# to test print_range in range.jl
566-
replstr(x) = stringmime("text/plain", x)
567-
@test replstr(1:4) == "4-element UnitRange{$Int}:\n 1,2,3,4"
568-
@test replstr(linspace(1,5,7)) == "7-element LinSpace{Float64}:\n 1.0,1.66667,2.33333,3.0,3.66667,4.33333,5.0"
569-
@test replstr(0:100.) == "101-element FloatRange{Float64}:\n 0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,…,94.0,95.0,96.0,97.0,98.0,99.0,100.0"
566+
replstrmime(x) = stringmime("text/plain", x)
567+
@test replstrmime(1:4) == "4-element UnitRange{$Int}:\n 1,2,3,4"
568+
@test replstrmime(linspace(1,5,7)) == "7-element LinSpace{Float64}:\n 1.0,1.66667,2.33333,3.0,3.66667,4.33333,5.0"
569+
@test replstrmime(0:100.) == "101-element FloatRange{Float64}:\n 0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,…,94.0,95.0,96.0,97.0,98.0,99.0,100.0"
570570
# next is to test a very large range, which should be fast because print_range
571571
# only examines spacing of the left and right edges of the range, sufficient
572572
# to cover the designated screen size.
573-
@test replstr(0:10^9) == "1000000001-element UnitRange{$Int}:\n 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,…,999999998,999999999,1000000000"
573+
@test replstrmime(0:10^9) == "1000000001-element UnitRange{$Int}:\n 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,…,999999998,999999999,1000000000"
574574

575575
@test sprint(io -> show(io,UnitRange(1,2))) == "1:2"
576576
@test sprint(io -> show(io,StepRange(1,2,5))) == "1:2:5"

0 commit comments

Comments
 (0)