-
Notifications
You must be signed in to change notification settings - Fork 251
/
Copy pathruntests.jl
executable file
·110 lines (96 loc) · 3.72 KB
/
runtests.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
global prev_theme=nothing
if haskey(ENV, "GADFLY_THEME")
prev_theme = ENV["GADFLY_THEME"]
pop!(ENV, "GADFLY_THEME")
end
using Base.Test, Gadfly, Compat
repo = LibGit2.GitRepo(dirname(@__DIR__))
branch = LibGit2.headname(repo)
outputdir = mapreduce(x->startswith(branch,x), |, ["master","(detac"]) ?
"cachedoutput" : "gennedoutput"
if VERSION>=v"0.6"
function mimic_git_log_n1(io::IO, head)
hash = LibGit2.GitHash(head)
println(io, "commit ",string(hash))
commit = LibGit2.GitCommit(repo, hash)
author = LibGit2.author(commit)
println(io, "Author: ",author.name," <",author.email,">")
datetime = Dates.unix2datetime(author.time + 60*author.time_offset)
println(io, "Date: ",Dates.format(datetime, "e u d HH:MM:SS YYYY"))
println(io, " ",LibGit2.message(commit))
end
function mimic_git_status(io::IO, head)
println(io, "On branch ",LibGit2.shortname(head))
status = LibGit2.GitStatus(repo)
println(io, "Changes not staged for commit:")
for i in 1:length(status)
entry = status[i]
index_to_workdir = unsafe_load(entry.index_to_workdir)
if index_to_workdir.status == Int(LibGit2.Consts.DELTA_MODIFIED)
println(io, " ", unsafe_string(index_to_workdir.new_file.path))
end
end
println(io, "Untracked files:")
for i in 1:length(status)
entry = status[i]
index_to_workdir = unsafe_load(entry.index_to_workdir)
if index_to_workdir.status == Int(LibGit2.Consts.DELTA_UNTRACKED)
println(io, " ", unsafe_string(index_to_workdir.new_file.path))
end
end
end
head = LibGit2.head(repo)
open(io->mimic_git_log_n1(io,head), joinpath(outputdir,"git.log"), "w")
open(io->mimic_git_status(io,head), joinpath(outputdir,"git.status"), "w")
end
backends = Dict{AbstractString, Function}(
"svg" => name -> SVG(joinpath(outputdir,"$(name).svg")),
"svgjs" => name -> SVGJS(joinpath(outputdir,"$(name).js.svg"), jsmode=:linkabs),
"png" => name -> PNG(joinpath(outputdir,"$(name).png")),
"ps" => name -> PS(joinpath(outputdir,"$(name).ps")),
"pdf" => name -> PDF(joinpath(outputdir,"$(name).pdf")),
"pgf" => name -> PGF(joinpath(outputdir,"$(name).tex"))
)
testdir = joinpath((@__DIR__),"testscripts")
testfiles = isempty(ARGS) ?
[splitext(filename)[1] for filename in readdir(testdir) if filename[1]!='.'] :
ARGS
@testset "Gadfly" begin
for filename in testfiles, (backend_name, backend) in backends
info(filename,'.',backend_name)
srand(1)
p = evalfile(joinpath(testdir, "$(filename).jl"))
@test typeof(p) in [Plot,Compose.Context]
r = draw(backend(filename), p)
@test typeof(r) in [Bool,Void]
end
end
output = open(string(outputdir,".html"), "w")
print(output,
"""
<!DOCTYPE html>
<html>
<meta charset="utf-8" />
<head>
<title>Gadfly Test Plots</title>
</head>
<body>
<script src="$(Compose.snapsvgjs)"></script>
<script src="$(Gadfly.gadflyjs)"></script>
<div style="width:900; margin:auto; text-align: center; font-family: sans-serif; font-size: 20pt;">
""")
for filename in testfiles
println(output, "<p>", filename, "</p>")
print(output, """<div id="$(filename)"><object type="image/svg+xml" data="$(outputdir)/$(filename).js.svg"></object></div>""")
print(output, """<img width="450px" src="$(outputdir)/$(filename).svg">""")
print(output, """<img width="450px" src="$(outputdir)/$(filename).png">\n""")
end
print(output,
"""
</div>
</body>
""")
close(output)
if prev_theme !== nothing
ENV["GADFLY_THEME"] = prev_theme
end