File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ require "spec_helper"
2
+ require "cc/engine/duplication"
3
+
4
+ module CC ::Engine ::Analyzers
5
+ RSpec . describe CommandLineRunner do
6
+ describe "#run" do
7
+ it "runs the command on the input and yields the output" do
8
+ runner = CommandLineRunner . new ( "cat; echo hi" )
9
+
10
+ output = runner . run ( "oh " ) { |o | o }
11
+
12
+ expect ( output ) . to eq "oh hi\n "
13
+ end
14
+
15
+
16
+ it "raises on errors" do
17
+ runner = CommandLineRunner . new ( "echo error output >&2; false" )
18
+
19
+ expect { runner . run ( "" ) } . to raise_error (
20
+ ParserError , /code 1:\n error output/
21
+ )
22
+ end
23
+
24
+ it "times out commands" do
25
+ runner = CommandLineRunner . new ( "sleep 3" , 0.01 )
26
+
27
+ expect { runner . run ( "" ) } . to raise_error ( Timeout ::Error )
28
+ end
29
+ end
30
+ end
31
+ end
You can’t perform that action at this time.
0 commit comments