Navigation Menu

Skip to content

Commit

Permalink
test: follow API change
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jun 2, 2014
1 parent 4e7a2dc commit 6f62798
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion test/test-analyzer.rb
Expand Up @@ -85,7 +85,7 @@ def test_no_report_summary
def run_analyzer(*arguments)
Tempfile.open("output.actual") do |output|
arguments << "--output" << output.path
@analyzer.run(*arguments)
@analyzer.run(arguments)
File.read(output.path)
end
end
Expand Down
31 changes: 24 additions & 7 deletions test/test-extractor.rb
Expand Up @@ -45,9 +45,8 @@ def test_multi
end

def test_no_specified
assert_raise(Groonga::QueryLog::Extractor::NoInputError) do
run_extractor
end
assert_equal("Error: Please specify input log files.\n",
run_extractor)
end
end

Expand Down Expand Up @@ -100,10 +99,28 @@ def test_exclude_command

private
def run_extractor(*arguments)
Tempfile.open("extract.actual") do |output|
arguments << "--output" << output.path
@extractor.run(*arguments)
File.read(output.path)
Tempfile.open("extract.output") do |output|
open_error_output do |error|
arguments << "--output" << output.path
if @extractor.run(arguments)
File.read(output.path)
else
File.read(error.path)
end
end
end
end

def open_error_output
Tempfile.open("extract.error") do |error|
error.sync = true
original_stderr = $stderr.dup
$stderr.reopen(error)
begin
yield(error)
ensure
$stderr.reopen(original_stderr)
end
end
end

Expand Down

0 comments on commit 6f62798

Please sign in to comment.