Skip to content

Commit

Permalink
Move all close after assert_screen because close before assert_screen…
Browse files Browse the repository at this point in the history
… is flaky.

Since yamatanooroti does not support close_input yet, all assert_screen should be done before close.
  • Loading branch information
tompng committed Sep 13, 2024
1 parent 1c3f9d9 commit 22a1a5a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions test/yamatanooroti/test_multiplatform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ def setup

def test_example
write(":a\n")
close
assert_screen(['prompt> :a', '=> :a', 'prompt>', '', ''])
assert_screen(<<~EOC)
prompt> :a
=> :a
prompt>
EOC
close
end

def test_result_repeatedly
Expand Down Expand Up @@ -43,25 +43,25 @@ def test_assert_screen_timeout

def test_auto_wrap
write("12345678901234567890123\n")
close
assert_screen(['prompt> 1234567890123456789012', '3', '=> 12345678901234567890123', 'prompt>', ''])
assert_screen(<<~EOC)
prompt> 1234567890123456789012
3
=> 12345678901234567890123
prompt>
EOC
close
end

def test_fullwidth
write(":あ\n")
close
assert_equal(['prompt> :あ', '=> :あ', 'prompt>', '', ''], result)
close
end

def test_two_fullwidth
write(":あい\n")
close
assert_equal(['prompt> :あい', '=> :あい', 'prompt>', '', ''], result)
close
end
end
10 changes: 5 additions & 5 deletions test/yamatanooroti/test_run_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ class Yamatanooroti::TestRunRuby < Yamatanooroti::TestCase
def test_winsize
start_terminal(5, 30, ['ruby', '-rio/console', '-e', 'puts(IO.console.winsize.inspect)'])
sleep 0.5
close
assert_screen(<<~EOC)
[5, 30]
EOC
close
end

def test_wait_for_startup_message
Expand All @@ -18,17 +18,17 @@ def test_wait_for_startup_message
# wait_for_startup_message option and close immediately by the close
# method at the next line. The next "bbb" after waiting 1 sec more doesn't
# be caught because I/O is already closed.
close
assert_screen(<<~EOC)
aaa
EOC
close
end

def test_move_cursor_and_render
start_terminal(5, 30, ['ruby', '-rio/console', '-e', 'STDOUT.puts(?A);STDOUT.goto(2,2);STDOUT.puts(?B)'])
assert_screen(/^ B/)
close
assert_equal(['A', '', ' B', '', ''], result)
close
end

def test_meta_key
Expand All @@ -37,22 +37,22 @@ def test_meta_key
write('aaa ccc')
write("\M-b")
write('bbb ')
close
assert_screen(<<~EOC)
>>>aaa bbb ccc
EOC
close
ensure
get_out_from_tmpdir
end

def test_assert_screen_takes_a_message_when_failed
start_terminal(5, 30, ['ruby', '-e', 'puts "aaa"'])
close
assert_raise_with_message Test::Unit::AssertionFailedError, /\Amessage when failed/ do
assert_screen(<<~EOC, 'message when failed')
bbb
EOC
end
close
end

private
Expand Down

0 comments on commit 22a1a5a

Please sign in to comment.