File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -11,21 +11,25 @@ import (
11
11
)
12
12
13
13
func main () {
14
- if len (os .Args ) <= 1 {
14
+ os .Exit (cmd (os .Args [1 :]))
15
+ }
16
+
17
+ func cmd (args []string ) int {
18
+ if len (args ) == 0 {
15
19
fmt .Printf ("**error: you need to give a directory containing a 'compile_commands.json' file\n " )
16
20
17
- os . Exit ( 1 )
21
+ return 1
18
22
}
19
23
20
- dir := os .ExpandEnv (os . Args [ 1 ])
24
+ dir := os .ExpandEnv (args [ 0 ])
21
25
fmt .Printf (":: inspecting [%s]...\n " , dir )
22
26
23
27
fname := filepath .Join (dir , "compile_commands.json" )
24
28
f , err := os .Open (fname )
25
29
if err != nil {
26
30
fmt .Printf ("**error: could not open file [%s]: %v\n " , fname , err )
27
31
28
- os . Exit ( 1 )
32
+ return 1
29
33
}
30
34
f .Close ()
31
35
@@ -68,4 +72,6 @@ func main() {
68
72
}
69
73
}
70
74
fmt .Printf (":: inspecting [%s]... [done]\n " , dir )
75
+
76
+ return 0
71
77
}
Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "testing"
5
+
6
+ "github.com/stretchr/testify/assert"
7
+ )
8
+
9
+ func TestGoClangCompDB (t * testing.T ) {
10
+ for _ , path := range []string {
11
+ "../../testdata" ,
12
+ } {
13
+ assert .Equal (t , 0 , cmd ([]string {path }))
14
+ }
15
+ }
You can’t perform that action at this time.
0 commit comments