[前][次][番号順一覧][スレッド一覧]

ruby-changes:65737

From: aycabta <ko1@a...>
Date: Sat, 3 Apr 2021 01:16:42 +0900 (JST)
Subject: [ruby-changes:65737] 0eb1491957 (master): [ruby/irb] Add yamatanooroti test example

https://git.ruby-lang.org/ruby.git/commit/?id=0eb1491957

From 0eb14919573379b86efc2cab79f0c2fb1b22923a Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Thu, 25 Mar 2021 18:58:25 +0900
Subject: [ruby/irb] Add yamatanooroti test example

https://github.com/ruby/irb/commit/279155fcee
---
 test/irb/yamatanooroti/test_rendering.rb | 54 ++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 test/irb/yamatanooroti/test_rendering.rb

diff --git a/test/irb/yamatanooroti/test_rendering.rb b/test/irb/yamatanooroti/test_rendering.rb
new file mode 100644
index 0000000..19c6c9a
--- /dev/null
+++ b/test/irb/yamatanooroti/test_rendering.rb
@@ -0,0 +1,54 @@ https://github.com/ruby/ruby/blob/trunk/test/irb/yamatanooroti/test_rendering.rb#L1
+require 'irb'
+
+begin
+  require 'yamatanooroti'
+
+  class IRB::TestRendering < Yamatanooroti::TestCase
+    def setup
+      @pwd = Dir.pwd
+      suffix = '%010d' % Random.rand(0..65535)
+      @tmpdir = File.join(File.expand_path(Dir.tmpdir), "test_irb_#{$$}_#{suffix}")
+      begin
+        Dir.mkdir(@tmpdir)
+      rescue Errno::EEXIST
+        FileUtils.rm_rf(@tmpdir)
+        Dir.mkdir(@tmpdir)
+      end
+      @irbrc_backup = ENV['IRBRC']
+      @irbrc_file = ENV['IRBRC'] = File.join(@tmpdir, 'temporaty_irbrc')
+      File.unlink(@irbrc_file) if File.exist?(@irbrc_file)
+    end
+
+    def teardown
+      FileUtils.rm_rf(@tmpdir)
+      ENV['IRBRC'] = @irbrc_backup
+      ENV.delete('RELINE_TEST_PROMPT') if ENV['RELINE_TEST_PROMPT']
+    end
+
+    def test_launch
+      write_irbrc <<~'LINES'
+        puts 'start IRB'
+      LINES
+      start_terminal(25, 80, %W{ruby -I#{@pwd}/lib -I#{@pwd}/../reline/lib #{@pwd}/exe/irb}, startup_message: 'start IRB')
+      write(<<~EOC)
+        'Hello, World!'
+      EOC
+      close
+      assert_screen(<<~EOC)
+        start IRB
+        irb(main):001:0> 'Hello, World!'
+        => "Hello, World!"
+        irb(main):002:0>
+      EOC
+    end
+
+    private def write_irbrc(content)
+      File.open(@irbrc_file, 'w') do |f|
+        f.write content
+      end
+    end
+  end
+rescue LoadError, NameError
+  # On Ruby repository, this test suit doesn't run because Ruby repo doesn't
+  # have the yamatanooroti gem.
+end
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]