Skip to content

Commit

Permalink
Merge pull request #14 from JuliaDebug/sp/1-11-compat
Browse files Browse the repository at this point in the history
fix: 1.11 compatibility
  • Loading branch information
pfitzseb committed Jun 10, 2024
2 parents ff1e668 + 8477c6e commit e6d2ece
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 17 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI
on:
pull_request:
push:
branches:
- master
tags: ["*"]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: ['1.1', '1.2', '1.3', '1.4', '1.5', '1.6', '1.7', '1.8', '1.9', '1.10', '1.11']
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
- uses: julia-actions/install-juliaup@v1
with:
julia-version: ${{matrix.julia-version}}
- uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
8 changes: 0 additions & 8 deletions .travis.yml

This file was deleted.

18 changes: 15 additions & 3 deletions src/TerminalRegressionTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ module TerminalRegressionTests
function EmulatedTerminal()
pty = VT100.create_pty(false)
new(
IOBuffer(UInt8[], true, true, true, true, typemax(Int)),
Base.TTY(pty.slave), pty,
pty.em, false, Condition(), Condition())
IOBuffer(UInt8[]; read = true, write = true, append = true, truncate = true, maxsize = typemax(Int)),
Base.TTY(pty.slave), pty,
pty.em, false, Condition(), Condition()
)
end
end
function Base.wait(term::EmulatedTerminal)
Expand Down Expand Up @@ -91,6 +92,17 @@ module TerminalRegressionTests
term.waiting = false
readuntil(term.input_buffer, delim; kwargs...)
end
function Base.readline(term::EmulatedTerminal; keep::Bool=false)
line = readuntil(term, 0x0a, keep=true)::Vector{UInt8}
i = length(line)
if keep || i == 0 || line[i] != 0x0a
return String(line)
elseif i < 2 || line[i-1] != 0x0d
return String(resize!(line,i-1))
else
return String(resize!(line,i-2))
end
end
REPL.Terminals.raw!(t::EmulatedTerminal, raw::Bool) =
ccall(:jl_tty_set_mode,
Int32, (Ptr{Cvoid},Int32),
Expand Down
13 changes: 7 additions & 6 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
using TerminalRegressionTests
using Test

const thisdir = dirname(@__FILE__)
TerminalRegressionTests.automated_test(
joinpath(thisdir,"TRT.multiout"),
joinpath(@__DIR__, "TRT.multiout"),
["Julia\n","Yes!!\n"]) do emuterm
print(emuterm, "Please enter your name: ")
name = strip(readline(emuterm))
@test name == "Julia"
print(emuterm, "\nHello $name. Do you like tests? ")
resp = strip(readline(emuterm))
@assert resp == "Yes!!"
@test resp == "Yes!!"
end

mktemp() do _, io
redirect_stderr(io) do
redirect_stdout(io) do
@test_throws ErrorException TerminalRegressionTests.automated_test(
joinpath(thisdir,"TRT2.multiout"),
joinpath(@__DIR__, "TRT2.multiout"),
[""]) do emuterm
println(emuterm, "Hello, world!") # generate with "wurld" rather than "world"
readline(emuterm) # needed to produce output?
Expand All @@ -36,9 +36,10 @@ function compare_replace(em, output; replace=nothing)
TerminalRegressionTests._compare(Vector{UInt8}(codeunits(output)), outbuf) || return false
return true
end
const cmp(a, b, decorator) = compare_replace(a, b; replace="wurld"=>"world")

cmp(a, b, decorator) = compare_replace(a, b; replace="wurld"=>"world")
TerminalRegressionTests.automated_test(cmp,
joinpath(thisdir,"TRT2.multiout"),
joinpath(@__DIR__, "TRT2.multiout"),
[""]) do emuterm
println(emuterm, "Hello, world!")
readline(emuterm)
Expand Down

0 comments on commit e6d2ece

Please sign in to comment.