Skip to content

Commit b333ecc

Browse files
MasonProtterIanButterworthoxinabox
authored
Add support for Sixel (take 2) (#136)
* add support for Sixel * add suppert for Sixel (take 2) Co-authored-by: Frames White <[email protected]> --------- Co-authored-by: Ian Butterworth <[email protected]> Co-authored-by: Frames White <[email protected]>
1 parent 77a37f3 commit b333ecc

File tree

8 files changed

+43
-28
lines changed

8 files changed

+43
-28
lines changed

.github/images/sixel_demo.png

172 KB
Loading

.github/workflows/UnitTest.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
uses: julia-actions/setup-julia@latest
3636
with:
3737
version: ${{ matrix.julia-version }}
38-
- uses: julia-actions/cache@v1
38+
- uses: julia-actions/cache@v2
3939
# rerun the test twice to (1) make sure regeneration works (2) generated references match what's uploaded
4040
- name: "Unit Test"
4141
shell: bash
@@ -45,10 +45,10 @@ jobs:
4545
julia --color=yes --check-bounds=yes --project -e "using Pkg; Pkg.test(coverage=true)"
4646
julia --color=yes --check-bounds=yes --project -e "using Pkg; Pkg.test(coverage=true)"
4747
- name: Upload Mismatched Files as a Build Artifact
48-
uses: actions/upload-artifact@v3
48+
uses: actions/upload-artifact@v5
4949
with:
50-
name: "Mismatched Files"
51-
path: "~/mismatches/"
50+
name: "Mismatched Files-${{ github.run_number }}"
51+
path: "~/mismatches/{}"
5252

5353
- uses: julia-actions/julia-processcoverage@latest
5454
- uses: codecov/codecov-action@v3

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
with:
2424
version: ${{ matrix.julia-version }}
2525
- name: Cache artifacts
26-
uses: actions/cache@v1
26+
uses: actions/cache@v4
2727
env:
2828
cache-name: cache-artifacts
2929
with:

Project.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
name = "ReferenceTests"
22
uuid = "324d217c-45ce-50fc-942e-d289b448e8cf"
3+
version = "0.10.6"
34
authors = ["Christof Stocker <[email protected]>", "Frames White <[email protected]>", "Johnny Chen <[email protected]>"]
4-
version = "0.10.5"
55

66
[deps]
77
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
88
DeepDiffs = "ab62b9b5-e342-54a8-a765-a90f495de1a6"
99
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
1010
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
1111
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
12-
LazyModules = "8cdb02fc-e678-4876-92c5-9defec4f444e"
1312
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1413
SHA = "ea8e919c-243c-51af-8825-aaa63cd721ce"
14+
Sixel = "45858cf5-a6b0-47a3-bbea-62219f50df47"
1515
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1616
XTermColors = "c8c2cc18-de81-4e68-b407-38a3a0c0491f"
1717

1818
[compat]
1919
BSON = "0.3"
20-
Colors = "0.10 - 0.13"
2120
CSVFiles = "1"
21+
Colors = "0.10 - 0.13"
2222
DataFrames = "0.21 - 0.22, 1"
2323
DeepDiffs = "1"
2424
Distances = "0.7 - 0.10"
2525
FileIO = "1"
2626
ImageCore = "0.8.1, 0.9, 0.10"
2727
ImageMagick = "0.7, 1"
2828
ImageTransformations = "0.8 - 0.10"
29-
LazyModules = "0.3"
30-
Plots = "= 1.39.0"
29+
Plots = "1.39.0"
30+
Sixel = "0.1.3"
3131
TestImages = "0.6, 1"
3232
XTermColors = "0.2"
3333
julia = "1.6"

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,16 @@ using ReferenceTests, TestImages
7373
![readme3](https://user-images.githubusercontent.com/10854026/30002971-3ebdc350-90b7-11e7-8f40-2fc8b59ce9e8.png)
7474
![readme4](https://user-images.githubusercontent.com/10854026/30002972-3edfff60-90b7-11e7-8bb5-8e647f9f4965.png)
7575

76-
Note that while a text-based storage of reference images can be
77-
convenient, proper image formats (e.g. `png`) are also supported
78-
by the package. Those, however, will require the proper `FileIO`
79-
backends to be installed.
76+
Proper image formats such as `.png` are also supported for full-res image testing. If your terminal
77+
[supports Sixel](https://www.arewesixelyet.com/), then ReferenceTests will display the full image
78+
in your terminal using (Sixel.jl)[https://github.com/JuliaIO/Sixel.jl]:
79+
80+
![sixel_demo](.github/images/sixel_demo.png)
81+
82+
Currently, Sixel is not able to automatically [detect if it is supported
83+
during package testing](https://github.com/JuliaLang/Pkg.jl/issues/3185),
84+
but it can be force-enable Sixel rendering of images by setting the
85+
environment variable `REFERENCETESTS_FORCE_SIXEL=true`.
8086

8187
Another special file extension is `sha256` which will cause the
8288
hash of the result of the given expression to be stored and

src/ReferenceTests.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
module ReferenceTests
22

3-
using LazyModules
4-
53
using Test
64
using Colors
75
using Distances
86
using FileIO
9-
@lazy import ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
10-
@lazy import XTermColors = "c8c2cc18-de81-4e68-b407-38a3a0c0491f"
7+
import ImageCore
8+
import XTermColors
119
using SHA
1210
using DeepDiffs
1311
using Random
12+
using Sixel
1413

1514
export
1615
@withcolor,

src/render.jl

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,25 @@ function render_item(::BeforeAfterLimited, item)
2525
show(io, "text/plain", item)
2626
read(io, String)
2727
end
28+
29+
should_use_sixel() = Sixel.is_sixel_supported() || parse(Bool, get(ENV, "REFERENCETESTS_FORCE_SIXEL", "false"))
30+
2831
function render_item(::BeforeAfterImage, item)
29-
io = color_buffer()
32+
io = should_use_sixel() ? PipeBuffer() : color_buffer()
3033
println(io, "eltype: ", eltype(item))
3134
println(io, "size: ", map(length, axes(item)))
3235
println(io, "thumbnail:")
33-
strs = @withcolor XTermColors.ascii_show(
34-
item,
35-
Base.invokelatest(XTermColors.TermColor8bit),
36-
:small,
37-
(20, 40)
38-
)
39-
print(io, join(strs, '\n'))
36+
if should_use_sixel()
37+
sixel_encode(io, item)
38+
else
39+
strs = @withcolor XTermColors.ascii_show(
40+
item,
41+
Base.invokelatest(XTermColors.TermColor8bit),
42+
:small,
43+
(20, 40)
44+
)
45+
print(io, join(strs, '\n'))
46+
end
4047
read(io, String)
4148
end
4249

test/runtests.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ else
2323
end
2424

2525
ambs = detect_ambiguities(ReferenceTests, Base, Core)
26-
@test isempty(ambs)
27-
26+
if VERSION>v"1.13.0-DEV.0"
27+
@test_broken isempty(ambs) # Ref https://github.com/JuliaImages/ImageCore.jl/issues/210
28+
else
29+
@test isempty(ambs)
30+
end
2831
# to properly test world age issues, the full test dependencies must be loaded later
2932
include("test_no_world_age_issues.jl")
3033

0 commit comments

Comments
 (0)