-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathpkgconfigusage_test.go
More file actions
46 lines (36 loc) · 1.18 KB
/
pkgconfigusage_test.go
File metadata and controls
46 lines (36 loc) · 1.18 KB
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
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.
package pkgconfigusage
import (
"os"
"path/filepath"
"testing"
"github.com/DataDog/datadog-agent/pkg/util/testutil"
"github.com/stretchr/testify/assert"
"golang.org/x/tools/go/analysis/analysistest"
)
func TestAll(t *testing.T) {
for key, value := range testutil.IsolatedGoBuildEnv(t.TempDir()) {
t.Setenv(key, value)
}
wd, err := os.Getwd()
if err != nil {
t.Fatalf("Failed to get wd: %s", err)
}
originalComponentPath := componentPath
componentPath = "comp"
t.Cleanup(func() {
componentPath = originalComponentPath
})
testdata := filepath.Join(filepath.Dir(filepath.Dir(wd)), "testdata")
plugin := &pkgconfigUsagePlugin{}
analyzers, err := plugin.BuildAnalyzers()
assert.NoError(t, err)
analyzer := analyzers[0]
// We do this to skip issues with import or other errors.
// We only care about parsing the test file and run the analyzer.
analyzer.RunDespiteErrors = true
analysistest.Run(t, testdata, analyzer, "./...")
}