Skip to content

adds support for julia v1 #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Documentation: https://github.com/JuliaCI/Appveyor.jl
environment:
matrix:
- julia_version: 1.0
- julia_version: 1.3
- julia_version: nightly
platform:
- x86
- x64
matrix:
allow_failures:
- julia_version: nightly
branches:
only:
- master
- /release-.*/
notifications:
- provider: Email
on_build_success: false
on_build_failure: false
on_build_status_changed: true
install:
- ps: iex ((new-object net.webclient).DownloadString("https://github.com/raw/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
build_script:
- echo "%JL_BUILD_SCRIPT%"
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"
test_script:
- echo "%JL_TEST_SCRIPT%"
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"
on_success:
- echo "%JL_CODECOV_SCRIPT%"
- C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"
14 changes: 4 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,14 @@ os:
- linux
- osx
julia:
- 0.6
- 1.0
- 1.3
- nightly
matrix:
allow_failures:
- julia: nightly
fast_finish: true
notifications:
email: false
# uncomment the following lines to override the default test script
#script:
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
# - julia -e 'Pkg.clone(pwd()); Pkg.build("TestSetExtensions"); Pkg.test("TestSetExtensions"; coverage=true)'
email: true
after_success:
# push coverage results to Coveralls
- julia -e 'cd(Pkg.dir("TestSetExtensions")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
# push coverage results to Codecov
- julia -e 'cd(Pkg.dir("TestSetExtensions")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
- julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())'
100 changes: 100 additions & 0 deletions Manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# This file is machine-generated - editing it directly is not advised

[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
git-tree-sha1 = "ed2c4abadf84c53d9e58510b5fc48912c2336fbb"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "2.2.0"

[[Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"

[[DeepDiffs]]
deps = ["Compat"]
git-tree-sha1 = "cd4648e98d5625c75b9ebbec516533ec1250ce57"
uuid = "ab62b9b5-e342-54a8-a765-a90f495de1a6"
version = "1.1.0"

[[DelimitedFiles]]
deps = ["Mmap"]
uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab"

[[Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"

[[InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[LibGit2]]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"

[[Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

[[LinearAlgebra]]
deps = ["Libdl"]
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

[[Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"

[[Pkg]]
deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[[Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"

[[Random]]
deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"

[[Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"

[[SharedArrays]]
deps = ["Distributed", "Mmap", "Random", "Serialization"]
uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383"

[[Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

[[SparseArrays]]
deps = ["LinearAlgebra", "Random"]
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[[Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[[Test]]
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[[Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
19 changes: 19 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name = "TestSetExtensions"
uuid = "98d24dd4-01ad-11ea-1b02-c9a08f80db04"
authors = []
version = "2.0.0"

[deps]
DeepDiffs = "ab62b9b5-e342-54a8-a765-a90f495de1a6"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"

[compat]
julia = "1"

[extras]
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Suppressor", "Test", "Logging"]
3 changes: 0 additions & 3 deletions REQUIRE

This file was deleted.

28 changes: 0 additions & 28 deletions appveyor.yml

This file was deleted.

2 changes: 1 addition & 1 deletion diffdemo.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Compat.Test
using Test
using TestSetExtensions

@testset ExtendedTestSet "Nice Diffs" begin
Expand Down
96 changes: 58 additions & 38 deletions src/TestSetExtensions.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
module TestSetExtensions

using Distributed, Test, DeepDiffs
using Test: AbstractTestSet, DefaultTestSet
using Test: Result, Fail, Error, Pass
export ExtendedTestSet, @includetests

using Compat.Test
import Compat.Test: record, finish
using Compat.Test: DefaultTestSet, AbstractTestSet
using Compat.Test: get_testset_depth, scrub_backtrace
using Compat.Test: Result, Pass, Fail, Error

using Base: @deprecate
@deprecate DottedTestSet ExtendedTestSet

using DeepDiffs

"""
Includes the given test files, given as a list without their ".jl" extensions.
If none are given it will scan the directory of the calling file and include all
Expand All @@ -27,19 +19,25 @@ macro includetests(testarg...)
error("@includetests takes zero or one argument")
end

rootfile = "$(__source__.file)"
mod = __module__

quote
tests = $tests
rootfile = @__FILE__
rootfile = $rootfile

if length(tests) == 0
tests = readdir(dirname(rootfile))
tests = filter(f->endswith(f, ".jl") && f!= basename(rootfile), tests)
else
tests = map(f->string(f, ".jl"), tests)
end

println();

for test in tests
print(splitext(test)[1], ": ")
include(test)
Base.include($mod, test)
println()
end
end
Expand All @@ -59,53 +57,75 @@ function ExtendedTestSet(desc; wrap=DefaultTestSet)
ExtendedTestSet{wrap}(desc)
end

function record(ts::ExtendedTestSet, res::Fail)
if myid() == 1
function Test.record(ts::ExtendedTestSet{T}, res::Fail) where {T}
if Distributed.myid() == 1
println("\n=====================================================")
print_with_color(:white, ts.wrapped.description, ": ")
if res.test_type == :test && isa(res.data,Expr) && res.data.head == :comparison
dd = deepdiff(res.data.args[1], res.data.args[3])
if !isa(dd, DeepDiffs.SimpleDiff)
# The test was an comparison between things we can diff,
# so display the diff
print_with_color(Base.error_color(), "Test Failed\n"; bold = true)
println(" Expression: ", res.orig_expr)
print_with_color(Base.info_color(), "\nDiff:\n")
display(dd)
println()
else
# fallback to the default printing if we don't have a pretty diff
printstyled(ts.wrapped.description, ": "; color = :white)

if res.test_type === :test
try
test_expr = if isa(res.data, Expr)
res.data
elseif isa(res.data, String)
Meta.parse(res.data)
end

if test_expr.head === :call && test_expr.args[1] === Symbol("==")
dd = if isa(test_expr.args[2], String) && isa(test_expr.args[3], String)
deepdiff(test_expr.args[2], test_expr.args[3])
elseif test_expr.args[2].head === :vect && test_expr.args[3].head === :vect
deepdiff(test_expr.args[2].args, test_expr.args[3].args)
elseif test_expr.args[2].head === :call && test_expr.args[3].head === :call &&
test_expr.args[2].args[1].head === :curly && test_expr.args[3].args[1].head === :curly
deepdiff(Base.eval(test_expr.args[2].args), Base.eval(test_expr.args[3].args))
end

if ! isa(dd, DeepDiffs.SimpleDiff)
# The test was an comparison between things we can diff,
# so display the diff
printstyled("Test Failed\n"; bold = true, color = Base.error_color())
println(" Expression: ", res.orig_expr)
printstyled("\nDiff:\n"; color = Base.info_color())
display(dd)
println()
else
# fallback to the default printing if we don't have a pretty diff
print(res)
end
end
catch ex
print(res)
end
else
# fallback to the default printing for non-comparisons
print(res)
end
Base.show_backtrace(STDOUT, scrub_backtrace(backtrace()))

Base.show_backtrace(stdout, Test.scrub_backtrace(backtrace()))
# show_backtrace doesn't print a trailing newline
println("\n=====================================================")
end
push!(ts.wrapped.results, res)
res, backtrace()
end

function record(ts::ExtendedTestSet, res::Error)
function Test.record(ts::ExtendedTestSet{T}, res::Error) where {T}
println("\n=====================================================")
record(ts.wrapped, res)
Test.record(ts.wrapped, res)
print("=====================================================\n")
end

function record(ts::ExtendedTestSet, res::Pass)
print_with_color(:green, ".")
record(ts.wrapped, res)
function Test.record(ts::ExtendedTestSet{T}, res::Pass) where {T}
printstyled("."; color = :green)
Test.record(ts.wrapped, res)
res
end

record(ts::ExtendedTestSet, res) = record(ts.wrapped, res)
Test.record(ts::ExtendedTestSet{T}, res) where {T} = Test.record(ts.wrapped, res)

function finish(ts::ExtendedTestSet)
get_testset_depth() == 0 && print("\n\n")
finish(ts.wrapped)
function Test.finish(ts::ExtendedTestSet{T}) where {T}
Test.get_testset_depth() == 0 && print("\n\n")
Test.finish(ts.wrapped)
end

end # module
1 change: 0 additions & 1 deletion test/REQUIRE

This file was deleted.

Loading