Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
f336b30
Enable windows CI
Blacksmoke16 Mar 3, 2023
c61c87a
Trim down to only windows for now
Blacksmoke16 Mar 3, 2023
2d19ba8
Remove nightlies too
Blacksmoke16 Mar 3, 2023
79ab790
Support reading terminal size on Windows
Blacksmoke16 Mar 3, 2023
93862c5
Re-enable nightly CI
Blacksmoke16 Mar 3, 2023
4200f4a
Actually push the new file :pitchfork:
Blacksmoke16 Mar 3, 2023
80ed52a
Support hidden input on windows
Blacksmoke16 Mar 3, 2023
0490c97
Add `LibC::STD_INPUT_HANDLE` const
Blacksmoke16 Mar 3, 2023
b6f83b9
Fix `ACON::Cursor#current_position`
Blacksmoke16 Mar 3, 2023
1a916bc
Merge branch 'master' into windows-ci
Blacksmoke16 Mar 9, 2023
fa2f1ce
Leverage a `System::EOL` newline character
Blacksmoke16 Mar 9, 2023
726b0e0
Normalize more newlines in specs
Blacksmoke16 Mar 9, 2023
761badd
Get framework component nearly working
Blacksmoke16 Mar 9, 2023
223038e
Get `framework` and `console` specs passing on windows
Blacksmoke16 Mar 10, 2023
4885cdf
Fix some minor issues
Blacksmoke16 Mar 11, 2023
0b79a19
Merge branch 'master' into windows-ci
Blacksmoke16 Mar 17, 2023
095a992
Handle non-tty cursor inputs within `cursor_spec.cr`
Blacksmoke16 Mar 17, 2023
0980be5
Re-enable other CI jobs
Blacksmoke16 Mar 17, 2023
0a417c2
Fix formatting
Blacksmoke16 Mar 17, 2023
b364849
Merge branch 'master' into windows-ci
Blacksmoke16 Mar 30, 2023
8cacdb1
Merge branch 'master' into windows-ci
Blacksmoke16 Apr 15, 2023
c6ac189
Use proper EOL on windows
Blacksmoke16 Apr 15, 2023
28ac94a
Merge branch 'master' into windows-ci
Blacksmoke16 May 19, 2023
79eba67
Fix `dotenv` spec failure on windows
Blacksmoke16 May 20, 2023
47dfe3b
Merge branch 'master' into windows-ci
Blacksmoke16 Jul 5, 2023
84ca8c3
Merge branch 'master' into windows-ci
Blacksmoke16 Sep 15, 2023
23e3c51
Merge branch 'master' into windows-ci
Blacksmoke16 Sep 17, 2023
6539f34
Remove now duplicate LibC const
Blacksmoke16 Sep 17, 2023
5d3bb34
Merge branch 'master' into windows-ci
Blacksmoke16 Dec 5, 2023
935ddc8
Merge branch 'master' into windows-ci
Blacksmoke16 Feb 3, 2024
90c2d89
Fix format issue
Blacksmoke16 Feb 3, 2024
ebee2e7
Merge master & resolve conflict
Blacksmoke16 Feb 3, 2024
a9f0860
Force line endings to `lf`
Blacksmoke16 Feb 3, 2024
46f37f7
Use `ACON::System::EOL` in more places
Blacksmoke16 Feb 3, 2024
62ef814
Try to debug failing tests on CI
Blacksmoke16 Feb 3, 2024
9e9cc55
Try not using the test script
Blacksmoke16 Feb 3, 2024
d29c65f
See what terminal size is on GHA
Blacksmoke16 Feb 4, 2024
4c23385
Maybe fix Windows API console size logic?
Blacksmoke16 Feb 4, 2024
c2ea365
Update missing reference
Blacksmoke16 Feb 4, 2024
c79f32c
Now check with libc code enabled again
Blacksmoke16 Feb 4, 2024
42e861e
Enable all specs again
Blacksmoke16 Feb 4, 2024
6cb1c03
Enable all component specs again
Blacksmoke16 Feb 4, 2024
bf63e51
Fix `spec` specs
Blacksmoke16 Feb 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.cr text eol=lf
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
os:
- ubuntu-latest
- macos-latest
# - windows-latest
- windows-latest
crystal:
- latest
- nightly
Expand All @@ -67,3 +67,4 @@ jobs:
SHARDS_OVERRIDE: shard.dev.yml
- name: Specs
run: ./scripts/test.sh
shell: bash
58 changes: 29 additions & 29 deletions src/components/console/spec/application_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct ApplicationTest < ASPEC::TestCase

protected def assert_file_equals_string(filepath : String, string : String, *, file : String = __FILE__, line : Int32 = __LINE__) : Nil
normalized_path = File.join __DIR__, "fixtures", filepath
string.should match(Regex.new(File.read(normalized_path))), file: file, line: line
string.should match(Regex.new(File.read(normalized_path).gsub ACON::System::EOL, "\n")), file: file, line: line
end

protected def ensure_static_command_help(application : ACON::Application) : Nil
Expand Down Expand Up @@ -340,7 +340,7 @@ struct ApplicationTest < ASPEC::TestCase

tester = ACON::Spec::ApplicationTester.new app
tester.run command: "foos:bar1", decorated: false
self.assert_file_equals_string "text/application_alternative_namespace.txt", tester.display
self.assert_file_equals_string "text/application_alternative_namespace.txt", tester.display true
end

def test_run_alternate_command_name : Nil
Expand Down Expand Up @@ -525,10 +525,10 @@ struct ApplicationTest < ASPEC::TestCase

app.catch_exceptions = true
tester.run command: "foo", decorated: false
self.assert_file_equals_string "text/application_renderexception1.txt", tester.display
self.assert_file_equals_string "text/application_renderexception1.txt", tester.display true

tester.run command: "foo", decorated: false, capture_stderr_separately: true
self.assert_file_equals_string "text/application_renderexception1.txt", tester.error_output
self.assert_file_equals_string "text/application_renderexception1.txt", tester.error_output true
tester.display.should be_empty

app.catch_exceptions = false
Expand All @@ -545,38 +545,38 @@ struct ApplicationTest < ASPEC::TestCase
tester = ACON::Spec::ApplicationTester.new app

tester.run command: "foo", decorated: false, capture_stderr_separately: true
self.assert_file_equals_string "text/application_renderexception1.txt", tester.error_output
self.assert_file_equals_string "text/application_renderexception1.txt", tester.error_output true

tester.run command: "foo", decorated: false, capture_stderr_separately: true, verbosity: :verbose
tester.error_output.should contain "Exception trace"

tester.run command: "list", "--foo": true, decorated: false, capture_stderr_separately: true
self.assert_file_equals_string "text/application_renderexception2.txt", tester.error_output
self.assert_file_equals_string "text/application_renderexception2.txt", tester.error_output true

app.add Foo3Command.new
tester = ACON::Spec::ApplicationTester.new app

tester.run command: "foo3:bar", decorated: false, capture_stderr_separately: true
self.assert_file_equals_string "text/application_renderexception3.txt", tester.error_output
self.assert_file_equals_string "text/application_renderexception3.txt", tester.error_output true

tester.run({"command" => "foo3:bar"}, decorated: false, verbosity: :verbose)
tester.display.should match /\[Exception\]\s*First exception/
tester.display.should match /\[Exception\]\s*Second exception/
tester.display.should match /\[Exception\]\s*Third exception/
tester.display(true).should match /\[Exception\]\s*First exception/
tester.display(true).should match /\[Exception\]\s*Second exception/
tester.display(true).should match /\[Exception\]\s*Third exception/

tester.run command: "foo3:bar", decorated: true
self.assert_file_equals_string "text/application_renderexception3_decorated.txt", tester.display
self.assert_file_equals_string "text/application_renderexception3_decorated.txt", tester.display true

tester.run command: "foo3:bar", decorated: true, capture_stderr_separately: true
self.assert_file_equals_string "text/application_renderexception3_decorated.txt", tester.error_output
self.assert_file_equals_string "text/application_renderexception3_decorated.txt", tester.error_output true

app = ACON::Application.new "foo"
app.auto_exit = false
ENV["COLUMNS"] = "32"
tester = ACON::Spec::ApplicationTester.new app

tester.run command: "foo", decorated: false, capture_stderr_separately: true
self.assert_file_equals_string "text/application_renderexception4.txt", tester.error_output
self.assert_file_equals_string "text/application_renderexception4.txt", tester.error_output true

ENV["COLUMNS"] = "120"
end
Expand Down Expand Up @@ -605,7 +605,7 @@ struct ApplicationTest < ASPEC::TestCase
tester = ACON::Spec::ApplicationTester.new app

tester.run command: "foo", decorated: false
self.assert_file_equals_string "text/application_renderexception_escapeslines.txt", tester.display
self.assert_file_equals_string "text/application_renderexception_escapeslines.txt", tester.display true

ENV["COLUMNS"] = "120"
end
Expand All @@ -620,7 +620,7 @@ struct ApplicationTest < ASPEC::TestCase
tester = ACON::Spec::ApplicationTester.new app

tester.run command: "foo", decorated: false
self.assert_file_equals_string "text/application_renderexception_linebreaks.txt", tester.display
self.assert_file_equals_string "text/application_renderexception_linebreaks.txt", tester.display true
end

def test_render_exception_escapes_lines_of_synopsis : Nil
Expand All @@ -633,7 +633,7 @@ struct ApplicationTest < ASPEC::TestCase

tester = ACON::Spec::ApplicationTester.new app
tester.run command: "foo", decorated: false
self.assert_file_equals_string "text/application_renderexception_synopsis_escapeslines.txt", tester.display
self.assert_file_equals_string "text/application_renderexception_synopsis_escapeslines.txt", tester.display true
end

def test_run_passes_io_thru : Nil
Expand All @@ -660,7 +660,7 @@ struct ApplicationTest < ASPEC::TestCase
tester = ACON::Spec::ApplicationTester.new app

tester.run decorated: false
self.assert_file_equals_string "text/application_run1.txt", tester.display
self.assert_file_equals_string "text/application_run1.txt", tester.display true
end

def test_run_help_command : Nil
Expand All @@ -672,10 +672,10 @@ struct ApplicationTest < ASPEC::TestCase
tester = ACON::Spec::ApplicationTester.new app

tester.run "--help": true, decorated: false
self.assert_file_equals_string "text/application_run2.txt", tester.display
self.assert_file_equals_string "text/application_run2.txt", tester.display true

tester.run "-h": true, decorated: false
self.assert_file_equals_string "text/application_run2.txt", tester.display
self.assert_file_equals_string "text/application_run2.txt", tester.display true
end

def test_run_help_list_command : Nil
Expand All @@ -687,10 +687,10 @@ struct ApplicationTest < ASPEC::TestCase
tester = ACON::Spec::ApplicationTester.new app

tester.run command: "list", "--help": true, decorated: false
self.assert_file_equals_string "text/application_run3.txt", tester.display
self.assert_file_equals_string "text/application_run3.txt", tester.display true

tester.run command: "list", "-h": true, decorated: false
self.assert_file_equals_string "text/application_run3.txt", tester.display
self.assert_file_equals_string "text/application_run3.txt", tester.display true
end

def test_run_ansi : Nil
Expand All @@ -713,10 +713,10 @@ struct ApplicationTest < ASPEC::TestCase
tester = ACON::Spec::ApplicationTester.new app

tester.run "--version": true, decorated: false
self.assert_file_equals_string "text/application_run4.txt", tester.display
self.assert_file_equals_string "text/application_run4.txt", tester.display true

tester.run "-V": true, decorated: false
self.assert_file_equals_string "text/application_run4.txt", tester.display
self.assert_file_equals_string "text/application_run4.txt", tester.display true
end

def test_run_quest : Nil
Expand Down Expand Up @@ -776,10 +776,10 @@ struct ApplicationTest < ASPEC::TestCase
tester = ACON::Spec::ApplicationTester.new app

tester.run command: "help", "--help": true, decorated: false
self.assert_file_equals_string "text/application_run5.txt", tester.display
self.assert_file_equals_string "text/application_run5.txt", tester.display true

tester.run command: "help", "-h": true, decorated: false
self.assert_file_equals_string "text/application_run5.txt", tester.display
self.assert_file_equals_string "text/application_run5.txt", tester.display true
end

def test_run_no_interaction : Nil
Expand All @@ -792,10 +792,10 @@ struct ApplicationTest < ASPEC::TestCase
tester = ACON::Spec::ApplicationTester.new app

tester.run command: "foo:bar", "--no-interaction": true, decorated: false
tester.display.should eq "execute called\n"
tester.display.should eq "execute called#{ACON::System::EOL}"

tester.run command: "foo:bar", "-n": true, decorated: false
tester.display.should eq "execute called\n"
tester.display.should eq "execute called#{ACON::System::EOL}"
end

def test_run_global_option_and_no_command : Nil
Expand Down Expand Up @@ -974,7 +974,7 @@ struct ApplicationTest < ASPEC::TestCase

tester = ACON::Spec::ApplicationTester.new app
tester.run interactive: false
tester.display.should eq "execute called\n"
tester.display.should eq "execute called#{ACON::System::EOL}"

# TODO: Test custom application default.
end
Expand All @@ -987,7 +987,7 @@ struct ApplicationTest < ASPEC::TestCase

tester = ACON::Spec::ApplicationTester.new app
tester.run "--fooopt": "opt", interactive: false
tester.display.should eq "execute called\nopt\n"
tester.display.should eq "execute called#{ACON::System::EOL}opt#{ACON::System::EOL}"
end

def test_run_custom_single_default_command : Nil
Expand Down
4 changes: 2 additions & 2 deletions src/components/console/spec/application_tester_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ struct ApplicationTesterTest < ASPEC::TestCase
end

def test_output : Nil
@tester.output.to_s.should eq "foo\n"
@tester.output.to_s.should eq "foo#{ACON::System::EOL}"
end

def test_display : Nil
@tester.display.to_s.should eq "foo\n"
@tester.display.to_s.should eq "foo#{ACON::System::EOL}"
end

def test_status : Nil
Expand Down
4 changes: 2 additions & 2 deletions src/components/console/spec/command_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,13 @@ describe ACON::Command do
it "interactive" do
tester = ACON::Spec::CommandTester.new TestCommand.new
tester.execute interactive: true
tester.display.should eq "interact called\nexecute called\n"
tester.display.should eq "interact called#{ACON::System::EOL}execute called#{ACON::System::EOL}"
end

it "non-interactive" do
tester = ACON::Spec::CommandTester.new TestCommand.new
tester.execute interactive: false
tester.display.should eq "execute called\n"
tester.display.should eq "execute called#{ACON::System::EOL}"
end

it "invalid option" do
Expand Down
4 changes: 2 additions & 2 deletions src/components/console/spec/command_tester_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ struct CommandTesterTest < ASPEC::TestCase
end

def test_output : Nil
@tester.output.to_s.should eq "foo\n"
@tester.output.to_s.should eq "foo#{ACON::System::EOL}"
end

def test_display : Nil
@tester.display.to_s.should eq "foo\n"
@tester.display.to_s.should eq "foo#{ACON::System::EOL}"
end

def test_display_before_calling_execute : Nil
Expand Down
6 changes: 5 additions & 1 deletion src/components/console/spec/commands/list_spec.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
require "../spec_helper"

private def normalize(input : String) : String
input.gsub ACON::System::EOL, "\n"
end

struct ListCommandTest < ASPEC::TestCase
def test_execute_lists_commands : Nil
app = ACON::Application.new "foo"
Expand Down Expand Up @@ -34,7 +38,7 @@ struct ListCommandTest < ASPEC::TestCase
tester = ACON::Spec::CommandTester.new app.get("list")
tester.execute command: "list", decorated: false

tester.display.should eq <<-OUTPUT
tester.display(true).should eq normalize <<-OUTPUT
foo 0.1.0

Usage:
Expand Down
5 changes: 3 additions & 2 deletions src/components/console/spec/cursor_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ struct CursorTest < ASPEC::TestCase
position.should eq({1, 1})
end

# TODO: Figure out a less brittle way of testing this.
def ptest_current_position_tty : Nil
def test_current_position_tty : Nil
pending! "Cursor input must be a TTY" unless STDIN.tty?

@cursor = ACON::Cursor.new @output

@cursor.move_to_position 10, 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ abstract struct AbstractDescriptorTestCase < ASPEC::TestCase
context = context.clone
context.raw_output = true
self.descriptor.describe output, object, context
output.to_s.strip.should eq expected.strip
self.normalize_output(output.to_s).should eq self.normalize_output(expected)
end

private def normalize_output(output : String) : String
output.gsub(ACON::System::EOL, "\n").strip
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ abstract struct AbstractQuestionHelperTest < ASPEC::TestCase
yield input
end

protected def assert_output_contains(string : String) : Nil
protected def assert_output_contains(string : String, normalize : Bool = false) : Nil
stream = @output.io
stream.rewind

stream.to_s.should contain string
output = stream.to_s

if normalize
output = output.gsub ACON::System::EOL, "\n"
end

output.should contain string
end
end
4 changes: 2 additions & 2 deletions src/components/console/spec/helper/athena_question_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ struct AthenaQuestionTest < AbstractQuestionHelperTest
@helper.ask input, @output, question
end

self.assert_output_contains <<-OUT
self.assert_output_contains <<-OUT, true
qqq:
[foo ] foo
[żółw ] bar
Expand All @@ -152,7 +152,7 @@ struct AthenaQuestionTest < AbstractQuestionHelperTest
@helper.ask input, @output, question
end

self.assert_output_contains <<-OUT
self.assert_output_contains <<-OUT, true
qqq:
[0] foo
>ccc>
Expand Down
10 changes: 7 additions & 3 deletions src/components/console/spec/helper/formatter_spec.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
require "../spec_helper"

private def normalize(input : String) : String
input.gsub ACON::System::EOL, "\n"
end

describe ACON::Helper::Formatter do
it "#format_section" do
ACON::Helper::Formatter.new.format_section("cli", "some text to display").should eq "<info>[cli]</info> some text to display"
Expand All @@ -11,7 +15,7 @@ describe ACON::Helper::Formatter do

formatter.format_block("Some text to display", "error").should eq "<error> Some text to display </error>"
formatter.format_block({"Some text to display", "foo bar"}, "error").should eq "<error> Some text to display </error>\n<error> foo bar </error>"
formatter.format_block("Some text to display", "error", true).should eq <<-BLOCK
formatter.format_block("Some text to display", "error", true).should eq normalize <<-BLOCK
<error> </error>
<error> Some text to display </error>
<error> </error>
Expand All @@ -21,7 +25,7 @@ describe ACON::Helper::Formatter do
it "formats with diacritic letters" do
formatter = ACON::Helper::Formatter.new

formatter.format_block("Du texte à afficher", "error", true).should eq <<-BLOCK
formatter.format_block("Du texte à afficher", "error", true).should eq normalize <<-BLOCK
<error> </error>
<error> Du texte à afficher </error>
<error> </error>
Expand All @@ -32,7 +36,7 @@ describe ACON::Helper::Formatter do
end

it "escapes < within the block" do
ACON::Helper::Formatter.new.format_block("<info>some info</info>", "error", true).should eq <<-BLOCK
ACON::Helper::Formatter.new.format_block("<info>some info</info>", "error", true).should eq normalize <<-BLOCK
<error> </error>
<error> \\<info>some info\\</info> </error>
<error> </error>
Expand Down
Loading