File tree 2 files changed +29
-0
lines changed
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,16 @@ def self.run_and_capture(*args, **kwargs)
35
35
{ out : stdout , err : stderr , success : status . exitstatus . zero? }
36
36
end
37
37
38
+ def self . merge_capture_results ( args )
39
+ result = { out : "" , err : "" , success : true }
40
+ args . each do |a |
41
+ result [ :out ] = result [ :out ] + a [ :out ]
42
+ result [ :err ] = result [ :err ] + a [ :err ]
43
+ result [ :success ] = a [ :success ] unless a [ :success ]
44
+ end
45
+ result
46
+ end
47
+
38
48
def self . run_and_output ( *args , **kwargs )
39
49
system ( *args , **kwargs )
40
50
end
Original file line number Diff line number Diff line change @@ -71,4 +71,23 @@ def with_tmpdir(path)
71
71
end
72
72
end
73
73
74
+ context "merge_capture_results" do
75
+ it "merges results" do
76
+ a1 = { out : "one" , err : "ONE" , success : true }
77
+ a2 = { out : "two" , err : "TWO" , success : false }
78
+ a3 = { out : "three" , err : "THREE" , success : true }
79
+ res = ArduinoCI ::Host . merge_capture_results ( [ a1 , a2 , a3 ] )
80
+ expect ( res [ :out ] ) . to eq ( "onetwothree" )
81
+ expect ( res [ :err ] ) . to eq ( "ONETWOTHREE" )
82
+ expect ( res [ :success ] ) . to eq ( false )
83
+ end
84
+
85
+ it "handles empty input" do
86
+ res = ArduinoCI ::Host . merge_capture_results ( [ ] )
87
+ expect ( res [ :out ] ) . to eq ( "" )
88
+ expect ( res [ :err ] ) . to eq ( "" )
89
+ expect ( res [ :success ] ) . to eq ( true )
90
+ end
91
+ end
92
+
74
93
end
You can’t perform that action at this time.
0 commit comments