diff --git a/.github/workflows/CI.yml b/.github/workflows/ci.yml similarity index 64% rename from .github/workflows/CI.yml rename to .github/workflows/ci.yml index 394ddc0..67df6a1 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,7 @@ jobs: matrix: version: - '1.0' + - '1.6' - '1' - 'nightly' os: @@ -42,12 +43,22 @@ jobs: - uses: julia-actions/julia-runtest@v1 - uses: julia-actions/julia-processcoverage@v1 - uses: codecov/codecov-action@v1 + # (NOT pull request) OR ( (pull request) AND (NOT from a fork) ) + # In this case, secrets are available, so we can use the `CODECOV_TOKEN`. + if: github.event_name != 'pull_request' || github.repository == github.event.pull_request.head.repo.full_name + with: + file: lcov.info + token: ${{ secrets.CODECOV_TOKEN }} + - uses: codecov/codecov-action@v1 + # (pull request) AND (from a fork) + # In this case, secrets are NOT available, so we have to rely on Codecov's "tokenless uploads for GitHub Actions" feature. + if: github.event_name == 'pull_request' && github.repository != github.event.pull_request.head.repo.full_name with: file: lcov.info - uses: coverallsapp/github-action@master with: - github-token: ${{ secrets.github_token }} path-to-lcov: lcov.info + github-token: ${{ secrets.GITHUB_TOKEN }} flag-name: run-${{ matrix.test_number }} parallel: true finish: @@ -57,5 +68,5 @@ jobs: - name: Coveralls Finished uses: coverallsapp/github-action@master with: - github-token: ${{ secrets.github_token }} + github-token: ${{ secrets.GITHUB_TOKEN }} parallel-finished: true diff --git a/Project.toml b/Project.toml index 4b6a451..5ed09e9 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "CoverageTools" uuid = "c36e975a-824b-4404-a568-ef97ca766997" authors = ["Iain Dunning "] -version = "1.2.4" +version = "1.2.5" [compat] julia = "0.7, 1" diff --git a/src/CoverageTools.jl b/src/CoverageTools.jl index 91e9bf1..30940c0 100644 --- a/src/CoverageTools.jl +++ b/src/CoverageTools.jl @@ -1,9 +1,3 @@ -####################################################################### -# CoverageTools.jl -# Input: Code coverage and memory allocations -# Output: Useful things -# https://github.com/JuliaCI/CoverageTools.jl -####################################################################### module CoverageTools export process_folder, process_file @@ -318,7 +312,7 @@ module CoverageTools for file in files fullfile = joinpath(folder, file) if isfile(fullfile) && iscovfile(fullfile, filename) - @info "Removing $fullfile" + @info("Removing $(fullfile)") rm(fullfile) end end @@ -327,4 +321,5 @@ module CoverageTools include("lcov.jl") include("memalloc.jl") include("parser.jl") -end + +end # module diff --git a/test/runtests.jl b/test/runtests.jl index cf86246..36c19e2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,11 +1,25 @@ using CoverageTools using Test -if VERSION < v"1.1-" +if Base.VERSION < v"1.1" isnothing(x) = false isnothing(x::Nothing) = true end +if Base.VERSION < v"1.4" + function only(x::Array) + i = iterate(x) + if i === nothing + throw(ArgumentError("Collection is empty, must contain exactly 1 element")) + end + (ret, state) = i::NTuple{2,Any} + if iterate(x, state) !== nothing + throw(ArgumentError("Collection has multiple elements, must contain exactly 1 element")) + end + return ret + end +end + withenv("DISABLE_AMEND_COVERAGE_FROM_SRC" => nothing) do @testset "iscovfile" begin @@ -199,11 +213,39 @@ end # testset end @test_throws Base.Meta.ParseError(msg) process_file(bustedfile, srcdir) end # testset - -@testset "types" begin - a = CoverageTools.MallocInfo(1, "", 1) - b = CoverageTools.MallocInfo(2, "", 1) - @test CoverageTools.sortbybytes(a, b) + +@testset "malloc.jl" begin + @testset "types" begin + a = CoverageTools.MallocInfo(1, "", 1) + b = CoverageTools.MallocInfo(2, "", 1) + @test CoverageTools.sortbybytes(a, b) + end end # testset +@testset "parser.jl" begin + @testset "function_body_lines!" begin + @testset "ast.head == :module" begin + code = """ + module Foo + eval() = "foo" + eval(x) = "bar" + f() = "baz" + end # module + """ + ast = Meta.parse(code) + # remove the top-level line number nodes + filter!(x -> !(x isa LineNumberNode), ast.args[end].args) + flines = [] + coverage = CoverageTools.CovCount[] + lineoffset = 1 + infunction = false + @test length(flines) == 0 + CoverageTools.function_body_lines!(flines, ast, coverage, lineoffset, infunction) + @test length(flines) == 1 + @test only(flines) == 4 + end + + end +end + end # withenv