Skip to content
Snippets Groups Projects
Commit a07e80f9 authored by Johan Grönqvist's avatar Johan Grönqvist
Browse files

Add code coverage testing

parent d2b2cf71
Branches
No related tags found
Loading
...@@ -17,3 +17,4 @@ ...@@ -17,3 +17,4 @@
/src/NeuralNetworks.ipynb /src/NeuralNetworks.ipynb
/examples/random_systems.ipynb /examples/random_systems.ipynb
/examples/ToolboxExamples.ipynb /examples/ToolboxExamples.ipynb
/test/coverage.ipynb
...@@ -6,6 +6,7 @@ version = "0.1.1" ...@@ -6,6 +6,7 @@ version = "0.1.1"
[deps] [deps]
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e" BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
ControlSystems = "a6e380b2-a6ca-5380-bf3e-84a91bcd477e" ControlSystems = "a6e380b2-a6ca-5380-bf3e-84a91bcd477e"
Coverage = "a2441757-f6aa-5fb2-8edb-039e3f45d037"
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c" Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
Hypatia = "b99e6be6-89ff-11e8-14f8-45c827f4f8f2" Hypatia = "b99e6be6-89ff-11e8-14f8-45c827f4f8f2"
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253" IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
...@@ -18,6 +19,7 @@ MosekTools = "1ec41992-ff65-5c91-ac43-2df89e9693a4" ...@@ -18,6 +19,7 @@ MosekTools = "1ec41992-ff65-5c91-ac43-2df89e9693a4"
NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd" NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
Optim = "429524aa-4258-5aef-a3af-852621145aeb" Optim = "429524aa-4258-5aef-a3af-852621145aeb"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45" Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
......
# -*- coding: utf-8 -*-
# ---
# jupyter:
# jupytext:
# text_representation:
# extension: .jl
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.16.4
# kernelspec:
# display_name: Julia 1.10.2
# language: julia
# name: julia-1.10
# ---
# %% [markdown]
# # Prelude
# %%
import Pkg
Pkg.activate("..")
Pkg.instantiate()
# %%
using Coverage
using Base.Filesystem
# %% [markdown]
# # Run tests, Collecting stats
# %%
for (d, ds, fs) in walkdir("../src")
for f in fs
if endswith(f, ".cov")
rm("$(d)/$(f)")
end
end
end
# %%
Pkg.test("IQC"; coverage=true)
# %%
coverage = process_folder("../src") # defaults to src/; alternatively, supply the folder name as argument
coverage = [ c for c in coverage if !occursin("ipynb_checkpoints", c.filename) ];
# %% [markdown]
# # Per file summary statistics
# %%
for cov in coverage
good = length([ c for c in cov.coverage if !isnothing(c) && !iszero(c) ])
total = length([ c for c in cov.coverage if !isnothing(c) ])
println("$(split(cov.filename, "/")[end]): $(good)/$(total)")
end
# %% [markdown]
# # Untested Functions and Macros
# %%
re_macro = r"^macro .*"
re_function = r"^function .*"
re_function_short = r"^[A-Za-z0-9z.]*\(.*\).*="
# %%
for cov in coverage
println("File: $(cov.filename)")
for (c, ) in zip(cov.coverage, split(cov.source, "\n"))
if isnothing(c) || iszero(c)
if occursin(re_macro, ) || occursin(re_function, ) || occursin(re_function_short, )
println()
end
end
end
end
# %%
# %%
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment