-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
216 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*.jl.cov | ||
*.jl.*.cov | ||
*.jl.mem | ||
Manifest.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
name = "EmpiricalCDFs" | ||
uuid = "0dcf7749-4f9f-5e13-9c57-506664207bbc" | ||
license = "MIT" | ||
version = "0.2.2" | ||
license= "MIT" | ||
|
||
[deps] | ||
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" | ||
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" | ||
|
||
[compat] | ||
Aqua = ">= 0.8" | ||
JET = ">= 0.0" | ||
Printf = ">= 0.0" | ||
Random = ">= 0.0" | ||
Statistics = "1" | ||
Test = ">= 0.0" | ||
julia = "1" | ||
|
||
[extras] | ||
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" | ||
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[targets] | ||
test = ["Test"] | ||
test = ["Test", "Aqua", "JET"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using EmpiricalCDFs | ||
using Aqua: Aqua | ||
|
||
const ThePackage = EmpiricalCDFs | ||
|
||
@testset "aqua deps compat" begin | ||
Aqua.test_deps_compat(ThePackage) | ||
end | ||
|
||
@testset "aqua unbound_args" begin | ||
Aqua.test_unbound_args(ThePackage) | ||
end | ||
|
||
@testset "aqua undefined exports" begin | ||
Aqua.test_undefined_exports(ThePackage) | ||
end | ||
|
||
# TODO: Not sure exactly which versions are ok. | ||
if VERSION >= v"1.7" | ||
@testset "aqua test ambiguities" begin | ||
Aqua.test_ambiguities([ThePackage, Core, Base]) | ||
end | ||
end | ||
|
||
@testset "aqua piracies" begin | ||
Aqua.test_piracies(ThePackage) | ||
end | ||
|
||
@testset "aqua project extras" begin | ||
Aqua.test_project_extras(ThePackage) | ||
end | ||
|
||
@testset "aqua state deps" begin | ||
Aqua.test_stale_deps(ThePackage) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
using Test | ||
using EmpiricalCDFs | ||
using JET | ||
|
||
const package_to_analyze = EmpiricalCDFs | ||
|
||
## Ignore these errors. The first string in the pair is | ||
## the report message. The second is the file it occurs in. | ||
## Not very precise, but ok for now. | ||
const SKIP_MATCHES = [ | ||
# Trying to print a Sym could raise this error. | ||
# ("type Nothing has no field den", "parameters.jl"), | ||
] | ||
|
||
## Skip reports for which return true | ||
## Skip reports for which return true | ||
const SKIP_REP_TESTS = [ | ||
# rep -> rep isa JET.UncaughtExceptionReport, # We intentionally throw MethodError | ||
# rep -> rep isa JET.BuiltinErrorReport, | ||
# rep -> string(rep) == "MethodErrorReport(no matching method found `eps(::Type{Union{}})`: eps(T::Type{Union{}}))", | ||
] | ||
|
||
## | ||
## JET. Static analysis of the package | ||
## | ||
|
||
function analyze_package(package_name=package_to_analyze) | ||
result = report_package( | ||
string(package_name); | ||
report_pass=JET.BasicPass() | ||
# ignored_modules=( | ||
# ) | ||
) | ||
reports = JET.get_reports(result) | ||
return reports | ||
end | ||
|
||
""" | ||
match_report(package, report::InferenceErrorReport, msg::String, file::String) | ||
Return `true` if the message is `msg` and the first file in the stack trace is `file`. | ||
`file` should be given relative to the `src` directory of `package`. | ||
""" | ||
function match_report(package, report, msg::String, file::String) | ||
hasproperty(report, :msg) || return false | ||
report.msg != msg && return false | ||
filepath = joinpath(dirname(pathof(package)), file) | ||
report_filepath = string(report.vst[1].file) | ||
return report_filepath == filepath | ||
end | ||
|
||
function match_reports(package, report, match_data::Vector) | ||
for (msg, file) in match_data | ||
match_report(package, report, msg, file) && return true | ||
end | ||
return false | ||
end | ||
|
||
function do_rep_skip_test(rep, skip_rep_tests=SKIP_REP_TESTS) | ||
for rep_test in skip_rep_tests | ||
rep_test(rep) && return true | ||
end | ||
return false | ||
end | ||
|
||
# Filter out reports that we don't consider failures. | ||
# We could flag some that could be fixed as broken tests. | ||
# This could be more fine grained. | ||
|
||
function filter_reports(reports, package) | ||
somereports = empty(reports) | ||
for rep in reports | ||
do_rep_skip_test(rep) && continue | ||
match_reports(package, rep, SKIP_MATCHES) && continue | ||
push!(somereports, rep) | ||
end | ||
return somereports | ||
end | ||
|
||
# print just some of the report | ||
function print_report(report) | ||
hasproperty(report, :msg) && println(report.msg) | ||
return hasproperty(report, :vst) && println(report.vst) | ||
end | ||
|
||
function run_reports() | ||
reports = analyze_package(package_to_analyze) | ||
somereports = filter_reports(reports, package_to_analyze) | ||
@show somereports | ||
number_of_ignored_jet_reports = length(reports) - length(somereports) | ||
@info string(number_of_ignored_jet_reports, " reports ignored.") | ||
@info string(length(somereports), " reports not ignored.") | ||
for rep in somereports | ||
print_report(rep) | ||
end | ||
@test isempty(somereports) | ||
return (somereports, reports) | ||
end | ||
|
||
run_reports() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters