@@ -79,7 +79,7 @@ func loadConfiguration() (*Configuration, error) {
79
79
return & cfg , nil
80
80
}
81
81
82
- func streamOutput (file * os.File , closer io.ReadCloser ) {
82
+ func streamOutput (file * os.File , closer io.ReadCloser , result * [] byte ) {
83
83
defer closer .Close ()
84
84
85
85
buffer := make ([]byte , 1024 )
@@ -93,36 +93,40 @@ func streamOutput(file *os.File, closer io.ReadCloser) {
93
93
if err != nil {
94
94
break
95
95
}
96
+ * result = append (* result , buffer [:n ]... )
96
97
}
97
98
}
98
99
99
- func runClangTidyCommand (cfg * Configuration , args []string ) error {
100
+ func runClangTidyCommand (cfg * Configuration , args []string ) ([] byte , [] byte , error ) {
100
101
cmd := exec .Command (cfg .ClangTidyPath , args ... )
101
102
stdout , err := cmd .StdoutPipe ()
102
103
if err != nil {
103
- return err
104
+ return nil , nil , err
104
105
}
105
106
106
107
stderr , err := cmd .StderrPipe ()
107
108
if err != nil {
108
- return err
109
+ return nil , nil , err
109
110
}
110
111
112
+ stdout_buffer := []byte {}
113
+ stderr_buffer := []byte {}
114
+
111
115
// stream out the output of the command
112
- go streamOutput (os .Stdout , stdout )
113
- go streamOutput (os .Stderr , stderr )
116
+ go streamOutput (os .Stdout , stdout , & stdout_buffer )
117
+ go streamOutput (os .Stderr , stderr , & stderr_buffer )
114
118
115
119
err = cmd .Start ()
116
120
if err != nil {
117
- return err
121
+ return nil , nil , err
118
122
}
119
123
120
124
err = cmd .Wait ()
121
125
if err != nil {
122
- return err
126
+ return nil , nil , err
123
127
}
124
128
125
- return nil
129
+ return stdout_buffer , stderr_buffer , nil
126
130
}
127
131
128
132
func shouldBypassCache (args []string ) bool {
@@ -180,7 +184,7 @@ func evaluateTidyCommand(cfg *Configuration, wd string, args []string, cache cac
180
184
}
181
185
182
186
// we need to run the command
183
- err := runClangTidyCommand (cfg , args )
187
+ stdout , _ , err := runClangTidyCommand (cfg , args )
184
188
if err != nil {
185
189
return err
186
190
}
@@ -193,6 +197,8 @@ func evaluateTidyCommand(cfg *Configuration, wd string, args []string, cache cac
193
197
if err != nil {
194
198
return err
195
199
}
200
+ } else {
201
+ content = stdout
196
202
}
197
203
err = cache .SaveEntry (fingerPrint , content )
198
204
if err != nil {
0 commit comments