Skip to content

Commit

Permalink
Merge branch 'master' into issue-10917
Browse files Browse the repository at this point in the history
  • Loading branch information
oprypin authored Jan 15, 2025
2 parents 7ba3ed3 + 2458e35 commit 8dd3807
Show file tree
Hide file tree
Showing 96 changed files with 1,129 additions and 180 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ parameters:
distribution-scripts-version:
description: "Git ref for version of https://github.com/crystal-lang/distribution-scripts/"
type: string
default: "588099d9e9de7ecf5925365796d30f832870e18c"
default: "2f56eecf233f52229b93eab4acd2bca51f0f8edf"
previous_crystal_base_url:
description: "Prefix for URLs to Crystal bootstrap compiler"
type: string
default: "https://github.com/crystal-lang/crystal/releases/download/1.14.0/crystal-1.14.0-1"
default: "https://github.com/crystal-lang/crystal/releases/download/1.15.0/crystal-1.15.0-1"

defaults:
environment: &env
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/interpreter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
test-interpreter_spec:
runs-on: ubuntu-24.04
container:
image: crystallang/crystal:1.14.0-build
image: crystallang/crystal:1.15.0-build
name: "Test Interpreter"
steps:
- uses: actions/checkout@v4
Expand All @@ -26,7 +26,7 @@ jobs:
build-interpreter:
runs-on: ubuntu-24.04
container:
image: crystallang/crystal:1.14.0-build
image: crystallang/crystal:1.15.0-build
name: Build interpreter
steps:
- uses: actions/checkout@v4
Expand All @@ -45,7 +45,7 @@ jobs:
needs: build-interpreter
runs-on: ubuntu-24.04
container:
image: crystallang/crystal:1.14.0-build
image: crystallang/crystal:1.15.0-build
strategy:
matrix:
part: [0, 1, 2, 3]
Expand All @@ -69,7 +69,7 @@ jobs:
needs: build-interpreter
runs-on: ubuntu-24.04
container:
image: crystallang/crystal:1.14.0-build
image: crystallang/crystal:1.15.0-build
name: "Test primitives_spec with interpreter"
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
strategy:
fail-fast: false
matrix:
crystal_bootstrap_version: [1.7.3, 1.8.2, 1.9.2, 1.10.1, 1.11.2, 1.12.2, 1.13.3, 1.14.0]
crystal_bootstrap_version: [1.7.3, 1.8.2, 1.9.2, 1.10.1, 1.11.2, 1.12.2, 1.13.3, 1.14.1, 1.15.0]
flags: [""]
include:
# libffi is only available starting from the 1.2.2 build images
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/llvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Install Crystal
uses: crystal-lang/install-crystal@v1
with:
crystal: "1.14.0"
crystal: "1.15.0"

- name: Build libllvm_ext
run: make -B deps
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mingw-w64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Install Crystal
uses: crystal-lang/install-crystal@v1
with:
crystal: "1.14.0"
crystal: "1.15.0"

- name: Cross-compile Crystal
run: make && make -B target=x86_64-windows-gnu release=1 interpreter=1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/openssl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
libssl_test:
runs-on: ubuntu-latest
name: "${{ matrix.pkg }}"
container: crystallang/crystal:1.14.0-alpine
container: crystallang/crystal:1.15.0-alpine
strategy:
fail-fast: false
matrix:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/regex-engine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
pcre:
runs-on: ubuntu-latest
name: "PCRE"
container: crystallang/crystal:1.14.0-alpine
container: crystallang/crystal:1.15.0-alpine
steps:
- name: Download Crystal source
uses: actions/checkout@v4
Expand All @@ -27,7 +27,7 @@ jobs:
pcre2:
runs-on: ubuntu-latest
name: "PCRE2"
container: crystallang/crystal:1.14.0-alpine
container: crystallang/crystal:1.15.0-alpine
steps:
- name: Download Crystal source
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wasm32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
jobs:
wasm32-test:
runs-on: ubuntu-24.04
container: crystallang/crystal:1.14.0-build
container: crystallang/crystal:1.15.0-build
steps:
- name: Download Crystal source
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/win_build_portable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
uses: crystal-lang/install-crystal@v1
id: install-crystal
with:
crystal: "1.14.0"
crystal: "1.15.0"

- name: Download Crystal source
uses: actions/checkout@v4
Expand Down
434 changes: 434 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions bin/ci
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ format() {
prepare_build() {
on_linux verify_linux_environment

on_osx curl -L https://github.com/crystal-lang/crystal/releases/download/1.14.0/crystal-1.14.0-1-darwin-universal.tar.gz -o ~/crystal.tar.gz
on_osx 'pushd ~;gunzip -c ~/crystal.tar.gz | tar xopf -;mv crystal-1.14.0-1 crystal;popd'
on_osx curl -L https://github.com/crystal-lang/crystal/releases/download/1.15.0/crystal-1.15.0-1-darwin-universal.tar.gz -o ~/crystal.tar.gz
on_osx 'pushd ~;gunzip -c ~/crystal.tar.gz | tar xopf -;mv crystal-1.15.0-1 crystal;popd'

# These commands may take a few minutes to run due to the large size of the repositories.
# This restriction has been made on GitHub's request because updating shallow
Expand Down Expand Up @@ -189,7 +189,7 @@ with_build_env() {

on_linux verify_linux_environment

export DOCKER_TEST_PREFIX="${DOCKER_TEST_PREFIX:=crystallang/crystal:1.14.0}"
export DOCKER_TEST_PREFIX="${DOCKER_TEST_PREFIX:=crystallang/crystal:1.15.0}"

case $ARCH in
x86_64)
Expand Down
2 changes: 1 addition & 1 deletion lib/.shards.info
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ shards:
version: 0.5.0
reply:
git: https://github.com/i3oris/reply.git
version: 0.3.1+git.commit.db423dae3dd34c6ba5e36174653a0c109117a167
version: 0.3.1+git.commit.13f7eba083f138dd063c68b859c8e315f44fb523
4 changes: 2 additions & 2 deletions lib/reply/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ It includes the following features:
* Hook for Auto formatting
* Hook for Auto indentation
* Hook for Auto completion (Experimental)
* History Reverse i-search
* Work on Windows 10

It doesn't support yet:
* History reverse i-search
* Customizable hotkeys
* Unicode characters

Expand Down Expand Up @@ -53,7 +53,7 @@ end
require "reply"
class MyReader < Reply::Reader
def prompt(io : IO, line_number : Int32, color? : Bool) : Nil
def prompt(io : IO, line_number : Int32, color : Bool) : Nil
# Display a custom prompt
end
Expand Down
4 changes: 2 additions & 2 deletions lib/reply/examples/crystal_repl.cr
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ CONTINUE_ERROR = [
WORD_DELIMITERS = {{" \n\t+-*/,;@&%<>^\\[](){}|.~".chars}}

class CrystalReader < Reply::Reader
def prompt(io : IO, line_number : Int32, color? : Bool) : Nil
io << "crystal".colorize.blue.toggle(color?)
def prompt(io : IO, line_number : Int32, color : Bool) : Nil
io << "crystal".colorize.blue.toggle(color)
io << ':'
io << sprintf("%03d", line_number)
io << "> "
Expand Down
35 changes: 34 additions & 1 deletion lib/reply/spec/expression_editor_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ module Reply
end

it "is aligned when prompt size change" do
editor = ExpressionEditor.new do |line_number, _color?|
editor = ExpressionEditor.new do |line_number, _color|
"*" * line_number + ">" # A prompt that increase its size at each line
end
editor.output = IO::Memory.new
Expand Down Expand Up @@ -428,6 +428,39 @@ module Reply
"****>5"
end

it "Don't mess up the terminal when the prompt is empty" do
editor = ExpressionEditor.new { "" }
editor.output = IO::Memory.new
editor.color = false
editor.height = 5
editor.width = 15

editor.update { editor << "Hello,\nWorld" }
editor.verify_output "\e[1G\e[J" \
"Hello,\n" \
"World"

editor.output = IO::Memory.new
editor.update { editor << '\n' }
editor.verify_output "\e[1A\e[1G\e[J" \
"Hello,\n" \
"World\n"

editor.output = IO::Memory.new
editor.update { editor << "1+1" }
editor.verify_output "\e[2A\e[1G\e[J" \
"Hello,\n" \
"World\n" \
"1+1"

editor.output = IO::Memory.new
editor.update { editor << '\n' }
editor.verify_output "\e[2A\e[1G\e[J" \
"Hello,\n" \
"World\n" \
"1+1\n"
end

# TODO:
# header
end
Expand Down
54 changes: 54 additions & 0 deletions lib/reply/spec/reader_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,60 @@ module Reply
SpecHelper.send(pipe_in, '\0')
end

it "searches on ctrl-r" do
reader = SpecHelper.reader(type: SpecReaderWithSearch)
pipe_out, pipe_in = IO.pipe

SEARCH_ENTRIES.each { |e| reader.history << e }

spawn do
reader.read_next(from: pipe_out)
end

SpecHelper.send(pipe_in, '\u0012') # Ctrl-r (search)
reader.search.verify("", open: true, failed: true)

SpecHelper.send(pipe_in, 'p')
reader.search.verify("p", open: true, failed: false)
reader.editor.verify("pp! i")
reader.history.index.should eq 3

SpecHelper.send(pipe_in, "ut")
reader.search.verify("put", open: true, failed: false)
reader.editor.verify(<<-END)
while i < 10
puts i
i += 1
end
END
reader.history.index.should eq 2

SpecHelper.send(pipe_in, "ss")
reader.search.verify("putss", open: true, failed: true)
reader.editor.verify("")
reader.history.index.should eq 5

SpecHelper.send(pipe_in, '\u{7f}') # back
reader.search.verify("puts", open: true, failed: false)
reader.editor.verify(<<-END)
while i < 10
puts i
i += 1
end
END
reader.history.index.should eq 2

SpecHelper.send(pipe_in, '\e') # back
reader.search.verify("", open: false, failed: false)
reader.editor.verify(<<-END)
while i < 10
puts i
i += 1
end
END
reader.history.index.should eq 2
end

it "resets" do
reader = SpecHelper.reader
pipe_out, pipe_in = IO.pipe
Expand Down
84 changes: 84 additions & 0 deletions lib/reply/spec/search_spec.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
module Reply
SEARCH_ENTRIES = [
[%(puts "Hello World")],
[%(i = 0)],
[
%(while i < 10),
%( puts i),
%( i += 1),
%(end),
],
[%(pp! i)],
[%("Bye")],
]

describe Search do
it "displays footer" do
search = SpecHelper.search
search.verify_footer("search: _", height: 1)

search.query = "foo"
search.verify_footer("search: foo_", height: 1)

search.failed = true
search.verify_footer("search: #{"foo".colorize.bold.red}_", height: 1)

search.failed = false
search.query = "foobar"
search.verify_footer("search: foobar_", height: 1)

search.close
search.verify_footer("", height: 0)
end

it "opens and closes" do
search = SpecHelper.search
search.query = "foo"
search.failed = true
search.verify(query: "foo", open: true, failed: true)

search.close
search.verify(query: "", open: false, failed: false)

search.query = "bar"
search.failed = true

search.open
search.verify(query: "bar", open: true, failed: false)
end

it "searches" do
search = SpecHelper.search
history = SpecHelper.history(SEARCH_ENTRIES)

search.search(history).should be_nil
search.verify("", failed: true)
history.verify(SEARCH_ENTRIES, index: 5)

search.query = "p"
search.search(history).should eq Search::SearchResult.new(3, [%(pp! i)], x: 0, y: 0)
history.verify(SEARCH_ENTRIES, index: 3)

search.query = "put"
search.search(history).should eq Search::SearchResult.new(2, SEARCH_ENTRIES[2], x: 2, y: 1)
history.verify(SEARCH_ENTRIES, index: 2)

search.query = "i"
search.search(history).should eq Search::SearchResult.new(1, ["i = 0"], x: 0, y: 0)
history.verify(SEARCH_ENTRIES, index: 1)

search.open
search.search(history).should eq Search::SearchResult.new(3, ["pp! i"], x: 4, y: 0)
history.verify(SEARCH_ENTRIES, index: 3)

search.open
search.search(history).should eq Search::SearchResult.new(2, SEARCH_ENTRIES[2], x: 2, y: 0)
history.verify(SEARCH_ENTRIES, index: 2)

search.query = "baz"
search.search(history).should be_nil
search.verify("baz", failed: true)
history.verify(SEARCH_ENTRIES, index: 5)
end
end
end
Loading

0 comments on commit 8dd3807

Please sign in to comment.