diff --git a/.JuliaFormatter.toml b/.JuliaFormatter.toml new file mode 100644 index 0000000..453925c --- /dev/null +++ b/.JuliaFormatter.toml @@ -0,0 +1 @@ +style = "sciml" \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..700707c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" # Location of package manifests + schedule: + interval: "weekly" diff --git a/.github/workflows/CompatHelper.yml b/.github/workflows/CompatHelper.yml index 2876f03..5577817 100644 --- a/.github/workflows/CompatHelper.yml +++ b/.github/workflows/CompatHelper.yml @@ -1,16 +1,43 @@ -name: CompatHelper on: schedule: - - cron: '00 00 * * *' + - cron: 0 0 * * * workflow_dispatch: +permissions: + contents: write + pull-requests: write jobs: CompatHelper: runs-on: ubuntu-latest steps: - - name: Pkg.add("CompatHelper") - run: julia -e 'using Pkg; Pkg.add("CompatHelper")' - - name: CompatHelper.main() + - name: Check if Julia is already available in the PATH + id: julia_in_path + run: which julia + continue-on-error: true + - name: Install Julia, but only if it is not already available in the PATH + uses: julia-actions/setup-julia@v1 + with: + version: "1" + arch: ${{ runner.arch }} + if: steps.julia_in_path.outcome != 'success' + - name: "Add the General registry via Git" + run: | + import Pkg + ENV["JULIA_PKG_SERVER"] = "" + Pkg.Registry.add("General") + shell: julia --color=yes {0} + - name: "Install CompatHelper" + run: | + import Pkg + name = "CompatHelper" + uuid = "aa819f21-2bde-4658-8897-bab36330d9b7" + version = "3" + Pkg.add(; name, uuid, version) + shell: julia --color=yes {0} + - name: "Run CompatHelper" + run: | + import CompatHelper + CompatHelper.main() + shell: julia --color=yes {0} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }} # optional - run: julia -e 'using CompatHelper; CompatHelper.main()' \ No newline at end of file + COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }} diff --git a/.github/workflows/SpellCheck.yml b/.github/workflows/SpellCheck.yml new file mode 100644 index 0000000..9146006 --- /dev/null +++ b/.github/workflows/SpellCheck.yml @@ -0,0 +1,15 @@ +name: Spell Check + +on: [pull_request] + +jobs: + typos-check: + name: Spell Check with Typos + runs-on: ubuntu-latest + steps: + - name: Checkout Actions Repository + uses: actions/checkout@v4 + - name: Check spelling + uses: crate-ci/typos@v1.18.0 + with: + config: ./_typos.toml diff --git a/.github/workflows/TagBot.yml b/.github/workflows/TagBot.yml index 623860f..0cd3114 100644 --- a/.github/workflows/TagBot.yml +++ b/.github/workflows/TagBot.yml @@ -4,6 +4,22 @@ on: types: - created workflow_dispatch: + inputs: + lookback: + default: "3" +permissions: + actions: read + checks: read + contents: write + deployments: read + issues: read + discussions: read + packages: read + pages: read + pull-requests: read + repository-projects: read + security-events: read + statuses: read jobs: TagBot: if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot' @@ -12,4 +28,4 @@ jobs: - uses: JuliaRegistries/TagBot@v1 with: token: ${{ secrets.GITHUB_TOKEN }} - ssh: ${{ secrets.DOCUMENTER_KEY }} \ No newline at end of file + ssh: ${{ secrets.DOCUMENTER_KEY }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ffb3336..38ad54b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,48 @@ name: CI on: - - push - - pull_request + pull_request: + branches: + - master + - dev + paths-ignore: + - "docs/**" + push: + branches: + - master + paths-ignore: + - "docs/**" jobs: + formatter: + runs-on: ${{ matrix.os }} + strategy: + matrix: + julia-version: [1] + julia-arch: [x86] + os: [ubuntu-latest] + steps: + - uses: julia-actions/setup-julia@v2 + with: + version: ${{ matrix.julia-version }} + + - uses: actions/checkout@v4 + - name: Install JuliaFormatter and format + # This will use the latest version by default but you can set the version like so: + # + # julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))' + run: | + julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="1.0.50"))' + julia -e 'using JuliaFormatter; format(".", verbose=true)' + - name: Format check + run: | + julia -e ' + out = Cmd(`git diff`) |> read |> String + if out == "" + exit(0) + else + @error "Some files have not been formatted !!!" + write(stdout, out) + exit(1) + end' test: name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} runs-on: ${{ matrix.os }} @@ -10,28 +50,32 @@ jobs: fail-fast: false matrix: version: - - '1.6' - - '1.9' - - 'nightly' + - "lts" + - "1" + - "pre" os: - ubuntu-latest - - macOS-latest - - windows-latest arch: - x64 - x86 - exclude: + include: + # test macOS and Windows with latest Julia only - os: macOS-latest - arch: x86 + arch: x64 + version: 1 + - os: windows-latest + arch: x64 + version: 1 - os: windows-latest arch: x86 + version: 1 steps: - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@v1 + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v2 with: version: ${{ matrix.version }} arch: ${{ matrix.arch }} - - uses: actions/cache@v1 + - uses: actions/cache@v4 env: cache-name: cache-artifacts with: @@ -44,15 +88,15 @@ jobs: - uses: julia-actions/julia-buildpkg@v1 - uses: julia-actions/julia-runtest@v1 - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v1 + - uses: codecov/codecov-action@v4 with: file: lcov.info docs: name: Documentation runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: julia-actions/setup-julia@v1 + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v2 with: version: "1" - run: | diff --git a/.github/workflows/register.yml b/.github/workflows/register.yml new file mode 100644 index 0000000..5b7cd3b --- /dev/null +++ b/.github/workflows/register.yml @@ -0,0 +1,16 @@ +name: Register Package +on: + workflow_dispatch: + inputs: + version: + description: Version to register or component to bump + required: true +jobs: + register: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: julia-actions/RegisterAction@latest + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/Project.toml b/Project.toml index 0817a61..655fb6e 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Bibliography" uuid = "f1be7e48-bf82-45af-a471-ae754a193061" authors = ["azzaare "] -version = "0.2.20" +version = "0.2.21" [deps] BibInternal = "2027ae74-3657-4b95-ae00-e2f7d55c3e64" @@ -9,12 +9,27 @@ BibParser = "13533e5b-e1c2-4e57-8cef-cac5e52f6474" DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" +TestItems = "1c621080-faea-4a02-84b6-bbd5e436b8fe" YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6" [compat] -BibInternal = "0.3.3" -BibParser = "0.2.1" +BibInternal = "0.3.7" +BibParser = "0.2.2" DataStructures = "0.18" +Dates = "1" FileIO = "1" +TestItems = "1" YAML = "0.4" -julia = "1.6" +julia = "1.10" + +[extras] +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" +ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" +FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" +JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b" +ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a" + +[targets] +test = ["Aqua", "ExplicitImports", "FileIO", "JET", "ReferenceTests", "Test", "TestItemRunner"] diff --git a/_typos.toml b/_typos.toml new file mode 100644 index 0000000..7a50782 --- /dev/null +++ b/_typos.toml @@ -0,0 +1,24 @@ +[default] +extend-ignore-re = [ + "iMatix" +] + +[default.extend-words] +annote = "annote" +inbrace = "inbrace" +BA = "BA" +FO = "FO" +ND = "ND" + +[default.extend-identifiers] +"CC-BY-NC-ND-1.0" = "CC-BY-NC-ND-1.0" +"CC-BY-NC-ND-2.0" = "CC-BY-NC-ND-2.0" +"CC-BY-NC-ND-2.5" = "CC-BY-NC-ND-2.5" +"CC-BY-NC-ND-3.0" = "CC-BY-NC-ND-3.0" +"CC-BY-NC-ND-3.0-IGO" = "CC-BY-NC-ND-3.0-IGO" +"CC-BY-NC-ND-4.0" = "CC-BY-NC-ND-4.0" +"CC-BY-ND-1.0" = "CC-BY-ND-1.0" +"CC-BY-ND-2.0" = "CC-BY-ND-2.0" +"CC-BY-ND-2.5" = "CC-BY-ND-2.5" +"CC-BY-ND-3.0" = "CC-BY-ND-3.0" +"CC-BY-ND-4.0" = "CC-BY-ND-4.0" \ No newline at end of file diff --git a/docs/make.jl b/docs/make.jl index 44b0668..7d99be2 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -3,7 +3,7 @@ using Documenter, Bibliography, BibParser, BibInternal makedocs( sitename = "Bibliography.jl", authors = "Jean-François BAFFIER", - repo="https://github.com/Humans-of-Julia/Bibliography.jl/blob/{commit}{path}#L{line}", + repo = "https://github.com/Humans-of-Julia/Bibliography.jl/blob/{commit}{path}#L{line}", format = Documenter.HTML( prettyurls = get(ENV, "CI", nothing) == "true" ), diff --git a/src/bibtex.jl b/src/bibtex.jl index e5f5948..ae43ea4 100644 --- a/src/bibtex.jl +++ b/src/bibtex.jl @@ -4,7 +4,8 @@ Import a BibTeX file or parse a BibTeX string and convert it to the internal bib The `check` keyword argument can be set to `:none` (or `nothing`), `:warn`, or `:error` to raise appropriate logs. """ function import_bibtex(input; check = :error) - return isfile(input) ? BibParser.parse_file(input; check) : BibParser.parse_entry(input; check) + return isfile(input) ? BibParser.parse_file(input; check) : + BibParser.parse_entry(input; check) end """ @@ -14,7 +15,7 @@ Make a string of `n` spaces. """ int_to_spaces(n) = repeat(" ", n) -const spaces = Dict{String,String}( +const spaces = Dict{String, String}( map(s -> (string(s) => int_to_spaces(BibInternal.space(s))), BibInternal.fields) ) @@ -126,6 +127,7 @@ function export_bibtex(e::Entry) e.fields["editor"] = names_to_strings(e.editors) eprint_to_bibtex!(e.fields, e.eprint) in_to_bibtex!(e.fields, e.in) + e.fields["note"] = e.note e.fields["title"] = e.title str = "@$(e.type == "eprint" ? "misc" : e.type){$(e.id),\n" diff --git a/src/cff.jl b/src/cff.jl index d5260d6..accd96a 100644 --- a/src/cff.jl +++ b/src/cff.jl @@ -1,5 +1,5 @@ -using Dates -using YAML +import Dates: Dates, Date +import YAML """ import_cff(input) -> Entry @@ -12,40 +12,39 @@ function import_cff(input) end const BIB_TO_CFF_TYPES = Dict{String, String}( - [ - "article" => "article" - "book" => "book" - "booklet" => "pamphlet" - "manual" => "manual" - "proceedings" => "proceedings" - "unpublished" => "unpublished" - ] + ["article" => "article" + "book" => "book" + "booklet" => "pamphlet" + "manual" => "manual" + "proceedings" => "proceedings" + "unpublished" => "unpublished"] ) """ export_cff(e::Entry, destination::String="CITATION.cff", version::String="1.2.0", add_preferred::Bool=true) -> Dict{String, Any} Export an `Entry` to a CFF file (default is `CITATION.cff`). """ -function export_cff(e::Entry; destination::String="CITATION.cff", version::String="1.2.0", add_preferred::Bool=true) +function export_cff(e::Entry; destination::String = "CITATION.cff", + version::String = "1.2.0", add_preferred::Bool = true) cff = Dict{String, Any}() # mandatory fields cff["authors"] = map( name -> Dict( - "family-names" => na_if_empty(name.last), - "given-names" => na_if_empty(name.first * name.middle), + "family-names" => na_if_empty(name.last), + "given-names" => na_if_empty(name.first * name.middle), "name-particle" => na_if_empty(name.particle), - "name-suffix" => na_if_empty(name.junior) + "name-suffix" => na_if_empty(name.junior) ), e.authors ) cff["cff-version"] = version - cff["message"] = "If you use this software, please cite it using the metadata from this file." - cff["title"] = e.title + cff["message"] = "If you use this software, please cite it using the metadata from this file." + cff["title"] = e.title - cff["doi"] = na_if_empty(e.access.doi) + cff["doi"] = na_if_empty(e.access.doi) cff["repository-code"] = na_if_empty(e.access.url) - cff["date-released"] = "$(cff_parse_date(e.date))" + cff["date-released"] = "$(cff_parse_date(e.date))" if add_preferred preferred = deepcopy(cff) @@ -53,15 +52,15 @@ function export_cff(e::Entry; destination::String="CITATION.cff", version::Strin delete!(preferred, "message") start = split(e.in.pages, "--") - preferred["start"] = na_if_empty(start[1]) - preferred["end"] = na_if_empty(length(start) == 2 ? start[2] : "") - preferred["journal"] = na_if_empty(e.in.journal) - preferred["issue"] = na_if_empty(e.in.number) - preferred["volume"] = na_if_empty(e.in.volume) + preferred["start"] = na_if_empty(start[1]) + preferred["end"] = na_if_empty(length(start) == 2 ? start[2] : "") + preferred["journal"] = na_if_empty(e.in.journal) + preferred["issue"] = na_if_empty(e.in.number) + preferred["volume"] = na_if_empty(e.in.volume) publisher = Dict{String, String}() publisher["name"] = na_if_empty(e.in.publisher) preferred["publisher"] = publisher - preferred["type"] = get(BIB_TO_CFF_TYPES, e.type, "generic") + preferred["type"] = get(BIB_TO_CFF_TYPES, e.type, "generic") cff["preferred-citation"] = preferred end diff --git a/src/csl.jl b/src/csl.jl index e69de29..8b13789 100644 --- a/src/csl.jl +++ b/src/csl.jl @@ -0,0 +1 @@ + diff --git a/src/select.jl b/src/select.jl index 88ee6b6..515bf91 100644 --- a/src/select.jl +++ b/src/select.jl @@ -7,11 +7,11 @@ Select a part of a bibliography based on a given selection set of keys. If complementary is true, selection designates which entries will not be kept. By default, complementary is set to false. """ function select( - bibliography::DataStructures.OrderedDict{String,Entry}, - selection::Vector{String}; - complementary::Bool=false, + bibliography::DataStructures.OrderedDict{String, Entry}, + selection::Vector{String}; + complementary::Bool = false ) - selected_bib = DataStructures.OrderedDict{String,Entry}() + selected_bib = DataStructures.OrderedDict{String, Entry}() old_keys = keys(bibliography) new_keys = complementary ? setdiff(old_keys, selection) : intersect(old_keys, selection) diff --git a/src/sort_bibliography.jl b/src/sort_bibliography.jl index 0e8841b..310540c 100644 --- a/src/sort_bibliography.jl +++ b/src/sort_bibliography.jl @@ -9,10 +9,10 @@ Implemented sorting rules for bibliography entry sorting. See also [`sort_bibliography!`](@ref). """ -const sorting_rules = Dict{Symbol,Vector{Symbol}}( +const sorting_rules = Dict{Symbol, Vector{Symbol}}( :nty => [:authors; :editors; :title; :date], :nyt => [:authors; :editors; :date; :title], - :y => [:date], + :y => [:date] ) """ @@ -37,7 +37,7 @@ Supported symbols for `sorting_rule` are: implemented `isless()` functions (string comparators). """ function sort_bibliography!( - bibliography::DataStructures.OrderedDict{String,Entry}, sorting_rule::Symbol=:key + bibliography::DataStructures.OrderedDict{String, Entry}, sorting_rule::Symbol = :key ) # TODO: allow Union{Symbol,Vector{Symbol}} for a arbitrary custom sorting order # this needs one additional type check and a check for allowed symbols in @@ -47,8 +47,8 @@ function sort_bibliography!( elseif sorting_rule in keys(sorting_rules) sort!( bibliography; - lt=(a, b) -> recursive_isless(a, b, sorting_rules[sorting_rule]), - by=x -> bibliography[x], + lt = (a, b) -> recursive_isless(a, b, sorting_rules[sorting_rule]), + by = x -> bibliography[x] ) else throw(ArgumentError("Unsupported sorting order!")) @@ -68,7 +68,7 @@ argument is a tuple consisting of symbols denoting the fields of the data type The `depth` argument is purely for iterating/recursive purposes. """ -function recursive_isless(a::Entry, b::Entry, fields::Vector{Symbol}, depth::Int=1)::Bool +function recursive_isless(a::Entry, b::Entry, fields::Vector{Symbol}, depth::Int = 1)::Bool depth > length(fields) && return false a_field = getfield(a, fields[depth]) b_field = getfield(b, fields[depth]) diff --git a/src/staticweb.jl b/src/staticweb.jl index 04e3212..406ffa1 100644 --- a/src/staticweb.jl +++ b/src/staticweb.jl @@ -1,4 +1,4 @@ -const type_to_label = Dict{String,String}([ +const type_to_label = Dict{String, String}([ "article" => "journal", "book" => "book", "booklet" => "booklet", @@ -12,7 +12,7 @@ const type_to_label = Dict{String,String}([ "phdthesis" => "doctoral thesis", "proceedings" => "proceedings", "techreport" => "report", - "unpublished" => "other", + "unpublished" => "other" ]) """ @@ -35,9 +35,9 @@ Format the name of an `Entry` for web export. - `names`: :full (full names) or :last (last names + first name abbreviation) """ function xnames( - entry, - editors=false; - names=:full, # Current options: :last, :full + entry, + editors = false; + names = :full # Current options: :last, :full ) # forces the names to be editors' name if the entry are Proceedings if !editors && entry.type ∈ ["proceedings"] @@ -72,7 +72,7 @@ function xin(entry) entry.in.journal, entry.in.volume * (entry.in.number != "" ? "($(entry.in.number))" : ""), entry.in.pages, - entry.date.year, + entry.date.year ] elseif entry.type == "book" temp = [entry.in.publisher, entry.in.address, entry.date.year] @@ -89,7 +89,7 @@ function xin(entry) entry.booktitle, isempty(entry.in.chapter) ? entry.in.pages : entry.in.chapter, entry.in.publisher, - entry.in.address, + entry.in.address ] elseif entry.type == "incollection" # TODO: check if this new or the old format is/was correct, that "editors" seems out of place (and the title was switched with the names)? @@ -99,7 +99,7 @@ function xin(entry) xnames(entry, true), entry.in.pages * ". " * entry.in.publisher, # TODO: conditional ". " if one of the strings is empty? entry.in.address, - entry.date.year, + entry.date.year ] elseif entry.type == "inproceedings" temp_last = entry.in.publisher != "" @@ -109,7 +109,7 @@ function xin(entry) entry.in.pages, entry.in.address, entry.date.year, - entry.in.publisher, + entry.in.publisher ] elseif entry.type == "manual" temp = [entry.in.organization, entry.in.address, entry.date.year] @@ -118,18 +118,15 @@ function xin(entry) (entry.type == "mastersthesis" ? "Master's" : "PhD") * " thesis", entry.in.school, entry.in.address, - entry.date.year, - ] - elseif entry.type == "misc" - temp_last = - get(entry.fields, "note", "") != "" && - entry.access.howpublished != "" && - entry.date.year != "" - temp = [ - entry.access.howpublished entry.date.year - get(entry.fields, "note", "") ] + elseif entry.type == "misc" + temp_last = get(entry.fields, "note", "") != "" && + entry.access.howpublished != "" && + entry.date.year != "" + temp = [entry.access.howpublished + entry.date.year + get(entry.fields, "note", "")] elseif entry.type == "proceedings" temp_last = entry.in.publisher != "" temp = [ @@ -137,7 +134,7 @@ function xin(entry) entry.in.series, entry.in.address, entry.date.year, - entry.in.publisher, + entry.in.publisher ] # TODO: check if this old line here was a hidden bug # str *= entry.in.publisher != "" ? ". $(entry.in.address)" : "" @@ -146,7 +143,7 @@ function xin(entry) entry.in.number != "" ? "Technical Report $(entry.in.number)" : "", entry.in.institution, entry.in.address, - entry.date.year, + entry.date.year ] elseif entry.type == "unpublished" temp = [get(entry.fields, "note", ""), entry.date.year] @@ -249,7 +246,8 @@ function Publication(entry) cite = export_bibtex(entry) abstract = get(entry.fields, "abstract", "") labels = xlabels(entry) - return Publication(id, type, title, names, in_, year, link, file, cite, abstract, labels) + return Publication( + id, type, title, names, in_, year, link, file, cite, abstract, labels) end """ diff --git a/test/Aqua.jl b/test/Aqua.jl new file mode 100644 index 0000000..8211a3b --- /dev/null +++ b/test/Aqua.jl @@ -0,0 +1,24 @@ +@testset "Aqua.jl" begin + # TODO: Fix the broken tests and remove the `broken = true` flag + Aqua.test_all( + Bibliography; + ambiguities = (broken = false,), + deps_compat = false, + piracies = (broken = false,) + ) + + @testset "Ambiguities: Bibliography" begin + Aqua.test_ambiguities(Bibliography;) + end + + @testset "Piracies: Bibliography" begin + Aqua.test_piracies(Bibliography;) + end + + @testset "Dependencies compatibility (no extras)" begin + Aqua.test_deps_compat( + Bibliography; + check_extras = false # ignore = [:Random] + ) + end +end diff --git a/test/ExplicitImports.jl b/test/ExplicitImports.jl new file mode 100644 index 0000000..ac18738 --- /dev/null +++ b/test/ExplicitImports.jl @@ -0,0 +1,3 @@ +@testset "Look for Explicit Imports" begin + @test check_no_implicit_imports(Bibliography) === nothing +end diff --git a/test/JET.jl b/test/JET.jl new file mode 100644 index 0000000..d7e92a1 --- /dev/null +++ b/test/JET.jl @@ -0,0 +1,3 @@ +@testset "Code linting (JET.jl)" begin + JET.test_package(Bibliography; target_defined_modules = true) +end diff --git a/test/Project.toml b/test/Project.toml deleted file mode 100644 index 8e558f0..0000000 --- a/test/Project.toml +++ /dev/null @@ -1,4 +0,0 @@ -[deps] -FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" -ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/test/TestItemRunner.jl b/test/TestItemRunner.jl new file mode 100644 index 0000000..cf86c5a --- /dev/null +++ b/test/TestItemRunner.jl @@ -0,0 +1,3 @@ +@testset "TestItemRunner" begin + @run_package_tests +end diff --git a/test/cff.jl b/test/cff.jl index 90a7366..bfcd97f 100644 --- a/test/cff.jl +++ b/test/cff.jl @@ -3,7 +3,7 @@ using ReferenceTests @testset "cff" begin bib = Bibliography.import_cff("../examples/CITATION.cff") - rm("CITATION.cff", force=true) + rm("CITATION.cff", force = true) Bibliography.export_cff(bib) # TODO - generate a test file for 32 bits architecture if Sys.WORD_SIZE == 64 diff --git a/test/internal.jl b/test/internal.jl new file mode 100644 index 0000000..950cfc4 --- /dev/null +++ b/test/internal.jl @@ -0,0 +1,60 @@ +using FileIO +using Test +using ReferenceTests + +@testset "FileIO" begin + for file in ["test.bib"] #, "xampl.bib"] #, "ignace_ref.bib"] + test_import = Bibliography.import_bibtex("../examples/$file") + result = Bibliography.export_web(test_import) + + # FIXME - this test is failing (probably due to changes in ReferenceTests.jl) + # test re-exporting to bib file + # result = Bibliography.export_bibtex("result.bib", test_import) + # Sys.WORD_SIZE == 64 && @test_reference "$file" result + + # if file == "test.bib" + # # test re-exporting a selection to bib file + # selection = ["CitekeyArticle", "CitekeyBook"] + # test_select = Bibliography.select(test_import, selection) + # result = Bibliography.export_bibtex("result.bib", test_select) + # Sys.WORD_SIZE == 64 && @test_reference "test-selection.bib" result + # end + + # rm("result.bib") + end + + testdata = """@inproceedings{demo2020proceedings, + organization = {DemoOrg}, + pages = {1--10}, + doi = {10.1000/001-1-001-00001-1_001}, + author = {Demo, D}, + note = {cited by 0}, + year = {2020}, + booktitle = {Demo Booktitle}, + title = {Demo Title} + }""" + + write("demo.bib", testdata) + @info "Testing import/export 1" + Bibliography.import_bibtex(testdata) + @info "Testing import/export 2" + mybib = Bibliography.import_bibtex("demo.bib") + @info "Testing import/export 3" + Bibliography.export_bibtex("demo_export.bib", mybib) + @info "Testing import/export 4" + mybib2 = Bibliography.import_bibtex("demo_export.bib") + @info "Testing import/export 5" + + rm("demo.bib") + rm("demo_export.bib") + + @info "Testing import/export 6" + include("sort_bibliography.jl") + @info "Testing import/export 7" + include("staticweb.jl") + @info "Testing import/export 8" + include("cff.jl") + @info "Testing import/export 9" + include("test-fileio.jl") + @info "Testing import/export 10" +end diff --git a/test/runtests.jl b/test/runtests.jl index b7861de..efb76af 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,49 +1,15 @@ using Bibliography -using FileIO -using Test -using ReferenceTests - -for file in ["test.bib"] #, "xampl.bib"] #, "ignace_ref.bib"] - test_import = Bibliography.import_bibtex("../examples/$file") - result = Bibliography.export_web(test_import) - - # FIXME - this test is failing (probably due to changes in ReferenceTests.jl) - # test re-exporting to bib file - # result = Bibliography.export_bibtex("result.bib", test_import) - # Sys.WORD_SIZE == 64 && @test_reference "$file" result - # if file == "test.bib" - # # test re-exporting a selection to bib file - # selection = ["CitekeyArticle", "CitekeyBook"] - # test_select = Bibliography.select(test_import, selection) - # result = Bibliography.export_bibtex("result.bib", test_select) - # Sys.WORD_SIZE == 64 && @test_reference "test-selection.bib" result - # end - - # rm("result.bib") +using Aqua +using ExplicitImports +using JET +using Test +using TestItemRunner + +@testset "Package tests: Bibliography" begin + include("internal.jl") + include("Aqua.jl") + include("ExplicitImports.jl") + include("JET.jl") + include("TestItemRunner.jl") end - -testdata = """@inproceedings{demo2020proceedings, - organization = {DemoOrg}, - pages = {1--10}, - doi = {10.1000/001-1-001-00001-1_001}, - author = {Demo, D}, - note = {cited by 0}, - year = {2020}, - booktitle = {Demo Booktitle}, - title = {Demo Title} -}""" - -write("demo.bib", testdata) -Bibliography.import_bibtex(testdata) -mybib = Bibliography.import_bibtex("demo.bib") -Bibliography.export_bibtex("demo_export.bib", mybib) -mybib2 = Bibliography.import_bibtex("demo_export.bib") - -rm("demo.bib") -rm("demo_export.bib") - -include("sort_bibliography.jl") -include("staticweb.jl") -include("cff.jl") -include("test-fileio.jl") diff --git a/test/sort_bibliography.jl b/test/sort_bibliography.jl index 108d2a8..6d2de6d 100644 --- a/test/sort_bibliography.jl +++ b/test/sort_bibliography.jl @@ -18,18 +18,16 @@ testbib = Bibliography.import_bibtex("../examples/test_sort.bib") @test_throws MethodError sort_bibliography!(testbib[testbib.keys[1]], :nyt) end -result = [ - "1998BBaA1a" - "1998BBbA2a" - "2007JJaAbe" - "2007JJbAbe" - "2010JJBaAaa" - "2010JJBbAaa" - "2011JJBcAaa" - "2018DJaMad" - "2018DJaMae" - "SaA3a2010" -] +result = ["1998BBaA1a" + "1998BBbA2a" + "2007JJaAbe" + "2007JJbAbe" + "2010JJBaAaa" + "2010JJBbAaa" + "2011JJBcAaa" + "2018DJaMad" + "2018DJaMae" + "SaA3a2010"] @testset "sort_bibliography! : Ordering: :key" begin sort_bibliography!(testbib) @test testbib.keys == result @@ -37,52 +35,46 @@ result = [ @test testbib.keys == result end -result = [ - "2007JJbAbe" - "2007JJaAbe" - "2018DJaMae" - "2018DJaMad" - "2011JJBcAaa" - "2010JJBaAaa" - "2010JJBbAaa" - "SaA3a2010" - "1998BBbA2a" - "1998BBaA1a" -] +result = ["2007JJbAbe" + "2007JJaAbe" + "2018DJaMae" + "2018DJaMad" + "2011JJBcAaa" + "2010JJBaAaa" + "2010JJBbAaa" + "SaA3a2010" + "1998BBbA2a" + "1998BBaA1a"] @testset "sort_bibliography! : Ordering: :nyt" begin sort_bibliography!(testbib, :nyt) @test testbib.keys == result end -result = [ - "2007JJbAbe" - "2007JJaAbe" - "2018DJaMae" - "2018DJaMad" - "2011JJBcAaa" - "2010JJBaAaa" - "2010JJBbAaa" - "SaA3a2010" - "1998BBaA1a" - "1998BBbA2a" -] +result = ["2007JJbAbe" + "2007JJaAbe" + "2018DJaMae" + "2018DJaMad" + "2011JJBcAaa" + "2010JJBaAaa" + "2010JJBbAaa" + "SaA3a2010" + "1998BBaA1a" + "1998BBbA2a"] @testset "sort_bibliography! : Ordering: :nty" begin sort_bibliography!(testbib, :nty) @test testbib.keys == result end -result = [ - "2007JJbAbe" - "2007JJaAbe" - "2018DJaMae" - "2018DJaMad" - "2011JJBcAaa" - "2010JJBaAaa" - "2010JJBbAaa" - "SaA3a2010" - "1998BBaA1a" - "1998BBbA2a" -] +result = ["2007JJbAbe" + "2007JJaAbe" + "2018DJaMae" + "2018DJaMad" + "2011JJBcAaa" + "2010JJBaAaa" + "2010JJBbAaa" + "SaA3a2010" + "1998BBaA1a" + "1998BBbA2a"] @testset "sort_bibliography! : Ordering: :y" begin sort_bibliography!(testbib, :nty) @test testbib.keys == result diff --git a/test/test-fileio.jl b/test/test-fileio.jl index 95f7353..bb4e115 100644 --- a/test/test-fileio.jl +++ b/test/test-fileio.jl @@ -25,4 +25,4 @@ @test_broken bib == bib2 rm("test-fileio.bib") end -end \ No newline at end of file +end diff --git a/test/test.bib.txt b/test/test.bib.txt index 6c7bda8..b62f182 100644 --- a/test/test.bib.txt +++ b/test/test.bib.txt @@ -73,7 +73,7 @@ key: CitekeyMastersthesis key: CitekeyMisc title: 'Pluto: The 'Other' Red Planet' names: 'NASA' - in: '\url{https://www.nasa.gov/nh/pluto-the-other-red-planet}, 2015. Accessed: 2018-12-06.' + in: '\url{https://www.nasa.gov/nh/pluto-the-other-red-planet}, 2015.' year: '2015' link: '' file: 'files/CitekeyMisc.pdf' @@ -105,7 +105,7 @@ key: CitekeyTechreport key: CitekeyUnpublished title: 'Evolution: a revised theory' names: 'Mohinder Suresh' - in: 'Well, a note, 2006.' + in: '2006.' year: '2006' link: '' file: 'files/CitekeyUnpublished.pdf' @@ -113,7 +113,7 @@ key: CitekeyUnpublished key: baffier2017experimental title: 'Experimental Study of Compressed Stack Algorithms in Limited Memory Environments' names: 'Jean-François Baffier, Yago Diez, Matias Korman' - in: '2017, Well, a note.' + in: '2017.' year: '2017' link: '' file: 'files/baffier2017experimental.pdf'