Skip to content

Commit e6d2ece

Browse files
authored
Merge pull request #14 from JuliaDebug/sp/1-11-compat
fix: 1.11 compatibility
2 parents ff1e668 + 8477c6e commit e6d2ece

File tree

4 files changed

+54
-17
lines changed

4 files changed

+54
-17
lines changed

Diff for: .github/workflows/CI.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- master
7+
tags: ["*"]
8+
9+
jobs:
10+
test:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
julia-version: ['1.1', '1.2', '1.3', '1.4', '1.5', '1.6', '1.7', '1.8', '1.9', '1.10', '1.11']
15+
os: [ubuntu-latest]
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: julia-actions/install-juliaup@v1
19+
with:
20+
julia-version: ${{matrix.julia-version}}
21+
- uses: actions/cache@v4
22+
env:
23+
cache-name: cache-artifacts
24+
with:
25+
path: ~/.julia/artifacts
26+
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
27+
restore-keys: |
28+
${{ runner.os }}-test-${{ env.cache-name }}-
29+
${{ runner.os }}-test-
30+
${{ runner.os }}-
31+
- uses: julia-actions/julia-buildpkg@v1
32+
- uses: julia-actions/julia-runtest@v1

Diff for: .travis.yml

-8
This file was deleted.

Diff for: src/TerminalRegressionTests.jl

+15-3
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ module TerminalRegressionTests
5454
function EmulatedTerminal()
5555
pty = VT100.create_pty(false)
5656
new(
57-
IOBuffer(UInt8[], true, true, true, true, typemax(Int)),
58-
Base.TTY(pty.slave), pty,
59-
pty.em, false, Condition(), Condition())
57+
IOBuffer(UInt8[]; read = true, write = true, append = true, truncate = true, maxsize = typemax(Int)),
58+
Base.TTY(pty.slave), pty,
59+
pty.em, false, Condition(), Condition()
60+
)
6061
end
6162
end
6263
function Base.wait(term::EmulatedTerminal)
@@ -91,6 +92,17 @@ module TerminalRegressionTests
9192
term.waiting = false
9293
readuntil(term.input_buffer, delim; kwargs...)
9394
end
95+
function Base.readline(term::EmulatedTerminal; keep::Bool=false)
96+
line = readuntil(term, 0x0a, keep=true)::Vector{UInt8}
97+
i = length(line)
98+
if keep || i == 0 || line[i] != 0x0a
99+
return String(line)
100+
elseif i < 2 || line[i-1] != 0x0d
101+
return String(resize!(line,i-1))
102+
else
103+
return String(resize!(line,i-2))
104+
end
105+
end
94106
REPL.Terminals.raw!(t::EmulatedTerminal, raw::Bool) =
95107
ccall(:jl_tty_set_mode,
96108
Int32, (Ptr{Cvoid},Int32),

Diff for: test/runtests.jl

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
using TerminalRegressionTests
22
using Test
33

4-
const thisdir = dirname(@__FILE__)
54
TerminalRegressionTests.automated_test(
6-
joinpath(thisdir,"TRT.multiout"),
5+
joinpath(@__DIR__, "TRT.multiout"),
76
["Julia\n","Yes!!\n"]) do emuterm
87
print(emuterm, "Please enter your name: ")
98
name = strip(readline(emuterm))
9+
@test name == "Julia"
1010
print(emuterm, "\nHello $name. Do you like tests? ")
1111
resp = strip(readline(emuterm))
12-
@assert resp == "Yes!!"
12+
@test resp == "Yes!!"
1313
end
1414

1515
mktemp() do _, io
1616
redirect_stderr(io) do
1717
redirect_stdout(io) do
1818
@test_throws ErrorException TerminalRegressionTests.automated_test(
19-
joinpath(thisdir,"TRT2.multiout"),
19+
joinpath(@__DIR__, "TRT2.multiout"),
2020
[""]) do emuterm
2121
println(emuterm, "Hello, world!") # generate with "wurld" rather than "world"
2222
readline(emuterm) # needed to produce output?
@@ -36,9 +36,10 @@ function compare_replace(em, output; replace=nothing)
3636
TerminalRegressionTests._compare(Vector{UInt8}(codeunits(output)), outbuf) || return false
3737
return true
3838
end
39-
const cmp(a, b, decorator) = compare_replace(a, b; replace="wurld"=>"world")
39+
40+
cmp(a, b, decorator) = compare_replace(a, b; replace="wurld"=>"world")
4041
TerminalRegressionTests.automated_test(cmp,
41-
joinpath(thisdir,"TRT2.multiout"),
42+
joinpath(@__DIR__, "TRT2.multiout"),
4243
[""]) do emuterm
4344
println(emuterm, "Hello, world!")
4445
readline(emuterm)

0 commit comments

Comments
 (0)