From bbeba97a15ba30751bd77cb219a50c5deb12b4d4 Mon Sep 17 00:00:00 2001 From: Jean-Francois Baffier Date: Mon, 5 Aug 2024 10:19:15 +0900 Subject: [PATCH 1/2] Improves tests. Fixes imports (#35) * Improves tests. Fixes imports * Make 1.8 the minimum julia requirement (can't wait for new LTS) * CI: Julia 1.8 --- .github/workflows/CI.yml | 2 +- .gitignore | 6 +++++- Project.toml | 6 ++++-- src/ConstraintCommons.jl | 4 ++-- src/nothing.jl | 5 +++-- src/symbols.jl | 3 ++- test/Aqua.jl | 4 ---- test/ExplicitImports.jl | 3 +++ test/JET.jl | 3 +++ test/runtests.jl | 7 +++++++ 10 files changed, 30 insertions(+), 13 deletions(-) create mode 100644 test/ExplicitImports.jl create mode 100644 test/JET.jl diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 2f18da0..58ad58e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -50,7 +50,7 @@ jobs: fail-fast: false matrix: version: - - "1.7" + - "1.8" - "1" - "pre" os: diff --git a/.gitignore b/.gitignore index e2f1f69..cb946a9 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,8 @@ /docs/build/ /docs/Manifest.toml -/perf/Manifest.toml \ No newline at end of file +/perf/Manifest.toml + +.gitignore + +.DS_Store \ No newline at end of file diff --git a/Project.toml b/Project.toml index 66c77c4..204cc4a 100644 --- a/Project.toml +++ b/Project.toml @@ -11,12 +11,14 @@ TestItems = "1c621080-faea-4a02-84b6-bbd5e436b8fe" Dictionaries = "0.4" TestItemRunner = "0.2, 1" TestItems = "0.1, 1" -julia = "1.7" +julia = "1.8" [extras] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" +ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" +JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a" [targets] -test = ["Aqua", "Test", "TestItemRunner"] +test = ["Aqua", "ExplicitImports", "JET", "Test", "TestItemRunner"] diff --git a/src/ConstraintCommons.jl b/src/ConstraintCommons.jl index 0aefa38..0c5b2be 100644 --- a/src/ConstraintCommons.jl +++ b/src/ConstraintCommons.jl @@ -1,8 +1,8 @@ module ConstraintCommons #!SECTION -- Imports -using Dictionaries -using TestItems +import Dictionaries: AbstractDictionary, Dictionary, set! +import TestItems: @testitem #!SECTION -- Exports diff --git a/src/nothing.jl b/src/nothing.jl index 9d8ff87..bfd88d5 100644 --- a/src/nothing.jl +++ b/src/nothing.jl @@ -15,6 +15,7 @@ consisempty(::Nothing) = true consisempty(items) = @inline isempty(items) @testitem "Set: nothing" tags=[:set, :nothing] begin - @test !(ConstraintCommons.consin(42, nothing)) - @test ConstraintCommons.consisempty(nothing) + import ConstraintCommons: consin, consisempty + @test !(consin(42, nothing)) + @test consisempty(nothing) end diff --git a/src/symbols.jl b/src/symbols.jl index 33db468..b11a4b0 100644 --- a/src/symbols.jl +++ b/src/symbols.jl @@ -8,5 +8,6 @@ function symcon(s1::Symbol, s2::Symbol, connector::AbstractString = "_") end @testitem "Symbols" tags=[:symbols] begin - @test ConstraintCommons.symcon(:a, :b) === :a_b + import ConstraintCommons: symcon + @test symcon(:a, :b) === :a_b end diff --git a/test/Aqua.jl b/test/Aqua.jl index 807aa76..3f1aa29 100644 --- a/test/Aqua.jl +++ b/test/Aqua.jl @@ -1,8 +1,4 @@ @testset "Aqua.jl" begin - import Aqua - import ConstraintCommons - import Dictionaries - # TODO: Fix the broken tests and remove the `broken = true` flag Aqua.test_all( ConstraintCommons; diff --git a/test/ExplicitImports.jl b/test/ExplicitImports.jl new file mode 100644 index 0000000..4b3f1f9 --- /dev/null +++ b/test/ExplicitImports.jl @@ -0,0 +1,3 @@ +@testset "Look for Explicit Imports" begin + @test check_no_implicit_imports(ConstraintCommons) === nothing +end diff --git a/test/JET.jl b/test/JET.jl new file mode 100644 index 0000000..51fda87 --- /dev/null +++ b/test/JET.jl @@ -0,0 +1,3 @@ +@testset "Code linting (JET.jl)" begin + JET.test_package(ConstraintCommons; target_defined_modules = true) +end diff --git a/test/runtests.jl b/test/runtests.jl index dda1c95..fab954e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,7 +1,14 @@ +using ConstraintCommons + +using Aqua +using ExplicitImports +using JET using Test using TestItemRunner @testset "Package tests: ConstraintCommons" begin include("Aqua.jl") + include("ExplicitImports.jl") + include("JET.jl") include("TestItemRunner.jl") end From bea06b2af79fcf7e1ce6e7193b73eabc5433b3df Mon Sep 17 00:00:00 2001 From: Jean-Francois Baffier Date: Mon, 5 Aug 2024 10:20:57 +0900 Subject: [PATCH 2/2] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 204cc4a..c546197 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ConstraintCommons" uuid = "e37357d9-0691-492f-a822-e5ea6a920954" authors = ["azzaare (jean-François BAFFIER)"] -version = "0.2.2" +version = "0.2.3" [deps] Dictionaries = "85a47980-9c8c-11e8-2b9f-f7ca1fa99fb4"