Skip to content

Commit 5dabbff

Browse files
committed
Moving to capture3 for implementation and adding a test ensuring that large RST files are processed
1 parent f0ffbd7 commit 5dabbff

File tree

3 files changed

+3005
-11
lines changed

3 files changed

+3005
-11
lines changed

Diff for: lib/github/markup/command_implementation.rb

+5-11
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,12 @@ def execute(command, target)
5050
end
5151
else
5252
def execute(command, target)
53-
output = Open3.popen3(*command) do |stdin, stdout, stderr, wait_thr|
54-
stdin.puts target
55-
stdin.close
53+
# capture3 blocks until both buffers are written to and the process terminates, but
54+
# it won't allow either buffer to fill up
55+
stdout, stderr, status = Open3.capture3(*command, stdin_data: target)
5656

57-
stdout_lines = stdout.readlines
58-
stderr_lines = stderr.readlines.join('').strip
59-
60-
raise CommandError.new(stderr_lines) unless wait_thr.value.success?
61-
62-
stdout_lines
63-
end
64-
sanitize(output.join(''), target.encoding)
57+
raise CommandError.new(stderr) unless status.success?
58+
sanitize(stdout, target.encoding)
6559
end
6660
end
6761

Diff for: test/markup_test.rb

+4
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,8 @@ def test_commonmarker_options
130130
assert_equal "&lt;style>.red{color: red;}&lt;/style>\n", GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, "<style>.red{color: red;}</style>", options: {commonmarker_opts: [:UNSAFE]})
131131
assert_equal "<style>.red{color: red;}</style>\n", GitHub::Markup.render_s(GitHub::Markups::MARKUP_MARKDOWN, "<style>.red{color: red;}</style>", options: {commonmarker_opts: [:UNSAFE], commonmarker_exts: [:autolink, :table, :strikethrough]})
132132
end
133+
134+
def test_large_document_with_command_implementation
135+
assert GitHub::Markup.render_s(:rst, File.read("test/markups/README_large.rst"))
136+
end
133137
end

0 commit comments

Comments
 (0)