diff --git a/.github/images/sixel_demo.png b/.github/images/sixel_demo.png new file mode 100644 index 0000000..c0d1db8 Binary files /dev/null and b/.github/images/sixel_demo.png differ diff --git a/.github/workflows/UnitTest.yml b/.github/workflows/UnitTest.yml index 456d3d1..d08de02 100644 --- a/.github/workflows/UnitTest.yml +++ b/.github/workflows/UnitTest.yml @@ -35,7 +35,7 @@ jobs: uses: julia-actions/setup-julia@latest with: version: ${{ matrix.julia-version }} - - uses: julia-actions/cache@v1 + - uses: julia-actions/cache@v2 # rerun the test twice to (1) make sure regeneration works (2) generated references match what's uploaded - name: "Unit Test" shell: bash @@ -45,10 +45,10 @@ jobs: julia --color=yes --check-bounds=yes --project -e "using Pkg; Pkg.test(coverage=true)" julia --color=yes --check-bounds=yes --project -e "using Pkg; Pkg.test(coverage=true)" - name: Upload Mismatched Files as a Build Artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v5 with: - name: "Mismatched Files" - path: "~/mismatches/" + name: "Mismatched Files-${{ github.run_number }}" + path: "~/mismatches/{}" - uses: julia-actions/julia-processcoverage@latest - uses: codecov/codecov-action@v3 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 8d4f6b0..b022bb3 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -23,7 +23,7 @@ jobs: with: version: ${{ matrix.julia-version }} - name: Cache artifacts - uses: actions/cache@v1 + uses: actions/cache@v4 env: cache-name: cache-artifacts with: diff --git a/Project.toml b/Project.toml index 2ee3dcf..f6f659d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ReferenceTests" uuid = "324d217c-45ce-50fc-942e-d289b448e8cf" +version = "0.10.6" authors = ["Christof Stocker ", "Frames White ", "Johnny Chen "] -version = "0.10.5" [deps] Colors = "5ae59095-9a9b-59fe-a467-6f913c188581" @@ -9,16 +9,16 @@ DeepDiffs = "ab62b9b5-e342-54a8-a765-a90f495de1a6" Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7" FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534" -LazyModules = "8cdb02fc-e678-4876-92c5-9defec4f444e" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce" +Sixel = "45858cf5-a6b0-47a3-bbea-62219f50df47" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" XTermColors = "c8c2cc18-de81-4e68-b407-38a3a0c0491f" [compat] BSON = "0.3" -Colors = "0.10 - 0.13" CSVFiles = "1" +Colors = "0.10 - 0.13" DataFrames = "0.21 - 0.22, 1" DeepDiffs = "1" Distances = "0.7 - 0.10" @@ -26,8 +26,8 @@ FileIO = "1" ImageCore = "0.8.1, 0.9, 0.10" ImageMagick = "0.7, 1" ImageTransformations = "0.8 - 0.10" -LazyModules = "0.3" -Plots = "= 1.39.0" +Plots = "1.39.0" +Sixel = "0.1.3" TestImages = "0.6, 1" XTermColors = "0.2" julia = "1.6" diff --git a/README.md b/README.md index 30d79cc..8992ab8 100644 --- a/README.md +++ b/README.md @@ -73,10 +73,16 @@ using ReferenceTests, TestImages ![readme3](https://user-images.githubusercontent.com/10854026/30002971-3ebdc350-90b7-11e7-8f40-2fc8b59ce9e8.png) ![readme4](https://user-images.githubusercontent.com/10854026/30002972-3edfff60-90b7-11e7-8bb5-8e647f9f4965.png) -Note that while a text-based storage of reference images can be -convenient, proper image formats (e.g. `png`) are also supported -by the package. Those, however, will require the proper `FileIO` -backends to be installed. +Proper image formats such as `.png` are also supported for full-res image testing. If your terminal +[supports Sixel](https://www.arewesixelyet.com/), then ReferenceTests will display the full image +in your terminal using (Sixel.jl)[https://github.com/JuliaIO/Sixel.jl]: + +![sixel_demo](.github/images/sixel_demo.png) + +Currently, Sixel is not able to automatically [detect if it is supported +during package testing](https://github.com/JuliaLang/Pkg.jl/issues/3185), +but it can be force-enable Sixel rendering of images by setting the +environment variable `REFERENCETESTS_FORCE_SIXEL=true`. Another special file extension is `sha256` which will cause the hash of the result of the given expression to be stored and diff --git a/src/ReferenceTests.jl b/src/ReferenceTests.jl index 226ee96..b547b0f 100644 --- a/src/ReferenceTests.jl +++ b/src/ReferenceTests.jl @@ -1,16 +1,15 @@ module ReferenceTests -using LazyModules - using Test using Colors using Distances using FileIO -@lazy import ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534" -@lazy import XTermColors = "c8c2cc18-de81-4e68-b407-38a3a0c0491f" +import ImageCore +import XTermColors using SHA using DeepDiffs using Random +using Sixel export @withcolor, diff --git a/src/render.jl b/src/render.jl index fc45241..b8eacd3 100644 --- a/src/render.jl +++ b/src/render.jl @@ -25,18 +25,25 @@ function render_item(::BeforeAfterLimited, item) show(io, "text/plain", item) read(io, String) end + +should_use_sixel() = Sixel.is_sixel_supported() || parse(Bool, get(ENV, "REFERENCETESTS_FORCE_SIXEL", "false")) + function render_item(::BeforeAfterImage, item) - io = color_buffer() + io = should_use_sixel() ? PipeBuffer() : color_buffer() println(io, "eltype: ", eltype(item)) println(io, "size: ", map(length, axes(item))) println(io, "thumbnail:") - strs = @withcolor XTermColors.ascii_show( - item, - Base.invokelatest(XTermColors.TermColor8bit), - :small, - (20, 40) - ) - print(io, join(strs, '\n')) + if should_use_sixel() + sixel_encode(io, item) + else + strs = @withcolor XTermColors.ascii_show( + item, + Base.invokelatest(XTermColors.TermColor8bit), + :small, + (20, 40) + ) + print(io, join(strs, '\n')) + end read(io, String) end diff --git a/test/runtests.jl b/test/runtests.jl index e30914a..8734163 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -23,8 +23,11 @@ else end ambs = detect_ambiguities(ReferenceTests, Base, Core) -@test isempty(ambs) - +if VERSION>v"1.13.0-DEV.0" + @test_broken isempty(ambs) # Ref https://github.com/JuliaImages/ImageCore.jl/issues/210 +else + @test isempty(ambs) +end # to properly test world age issues, the full test dependencies must be loaded later include("test_no_world_age_issues.jl")