forked from opensibyl/sibyl2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextract_fs_test.go
95 lines (86 loc) · 2.07 KB
/
extract_fs_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package sibyl2
import (
"testing"
"github.com/opensibyl/sibyl2/pkg/core"
"github.com/opensibyl/sibyl2/pkg/extractor"
)
func TestExtract(t *testing.T) {
fileResult, err := Extract(".", &ExtractConfig{
LangType: core.LangGo,
ExtractType: extractor.TypeExtractFunction,
})
if err != nil {
panic(err)
}
for _, each := range fileResult {
core.Log.Debugf("path: %v, %v", each.Path, each.Units)
}
}
func TestExtractWithGuess(t *testing.T) {
fileResult, err := Extract(".", &ExtractConfig{
ExtractType: extractor.TypeExtractFunction,
})
if err != nil {
panic(err)
}
for _, each := range fileResult {
core.Log.Debugf("path: %v, %v", each.Path, each.Units)
}
}
func TestExtractFunctionWithGuess(t *testing.T) {
fileResult, err := ExtractFunction(".", &ExtractConfig{})
if err != nil {
panic(err)
}
for _, each := range fileResult {
core.Log.Debugf("path: %v, %v", each.Path, each.Units)
}
}
func TestExtractSymbol(t *testing.T) {
fileResult, err := ExtractSymbol(".", &ExtractConfig{})
if err != nil {
panic(err)
}
for _, each := range fileResult {
core.Log.Debugf("path: %s, %v", each.Path, each.Units)
}
}
func TestExtractFile(t *testing.T) {
fileResult, err := Extract("./extract.go", &ExtractConfig{
LangType: core.LangGo,
ExtractType: extractor.TypeExtractFunction,
})
if err != nil {
panic(err)
}
for _, each := range fileResult {
core.Log.Debugf("path: %v, %v", each.Path, each.Units)
}
}
func TestExtractClazz(t *testing.T) {
fileResult, err := ExtractClazz("./extract.go", &ExtractConfig{
LangType: core.LangGo,
})
if err != nil {
panic(err)
}
for _, each := range fileResult {
core.Log.Infof("path: %v, %v", each.Path, each.Units)
}
}
func BenchmarkExtract(b *testing.B) {
// with cache: 79614514 ns/op
// no cache: 294940375 ns/op
for i := 0; i < b.N; i++ {
fileResult, err := Extract(".", &ExtractConfig{
LangType: core.LangGo,
ExtractType: extractor.TypeExtractFunction,
})
if err != nil {
panic(err)
}
for _, each := range fileResult {
core.Log.Debugf("path: %v, %v", each.Path, each.Units)
}
}
}