Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit 4f22124

Browse files
spenczarcarolynvs
authored andcommitted
Add importer for github.com/LK4D4/vndr (#978)
1 parent c20daf3 commit 4f22124

File tree

12 files changed

+545
-22
lines changed

12 files changed

+545
-22
lines changed

cmd/dep/glide_importer_test.go

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import (
1818
"github.com/pkg/errors"
1919
)
2020

21-
const testGlideProjectRoot = "github.com/golang/notexist"
22-
2321
var (
2422
discardLogger = log.New(ioutil.Discard, "", 0)
2523
)
@@ -110,7 +108,7 @@ func TestGlideConfig_Convert(t *testing.T) {
110108
yaml: glideYaml{
111109
ExcludeDirs: []string{"samples"},
112110
},
113-
projectRoot: testGlideProjectRoot,
111+
projectRoot: testProjectRoot,
114112
wantIgnoreCount: 1,
115113
wantIgnoredPackages: []string{"github.com/golang/notexist/samples"},
116114
},
@@ -119,15 +117,15 @@ func TestGlideConfig_Convert(t *testing.T) {
119117
Name: "github.com/golang/mismatched-package-name",
120118
ExcludeDirs: []string{"samples"},
121119
},
122-
projectRoot: testGlideProjectRoot,
120+
projectRoot: testProjectRoot,
123121
wantIgnoreCount: 1,
124122
wantIgnoredPackages: []string{"github.com/golang/notexist/samples"},
125123
},
126124
"bad input, empty package name": {
127125
yaml: glideYaml{
128126
Imports: []glidePackage{{Name: ""}},
129127
},
130-
projectRoot: testGlideProjectRoot,
128+
projectRoot: testProjectRoot,
131129
wantConvertErr: true,
132130
},
133131
}
@@ -243,10 +241,10 @@ func TestGlideConfig_Import(t *testing.T) {
243241
h.Must(err)
244242
defer sm.Release()
245243

246-
h.TempDir(filepath.Join("src", testGlideProjectRoot))
247-
h.TempCopy(filepath.Join(testGlideProjectRoot, glideYamlName), "glide/glide.yaml")
248-
h.TempCopy(filepath.Join(testGlideProjectRoot, glideLockName), "glide/glide.lock")
249-
projectRoot := h.Path(testGlideProjectRoot)
244+
h.TempDir(filepath.Join("src", testProjectRoot))
245+
h.TempCopy(filepath.Join(testProjectRoot, glideYamlName), "glide/glide.yaml")
246+
h.TempCopy(filepath.Join(testProjectRoot, glideLockName), "glide/glide.lock")
247+
projectRoot := h.Path(testProjectRoot)
250248

251249
// Capture stderr so we can verify output
252250
verboseOutput := &bytes.Buffer{}
@@ -257,7 +255,7 @@ func TestGlideConfig_Import(t *testing.T) {
257255
t.Fatal("Expected the importer to detect the glide configuration files")
258256
}
259257

260-
m, l, err := g.Import(projectRoot, testGlideProjectRoot)
258+
m, l, err := g.Import(projectRoot, testProjectRoot)
261259
h.Must(err)
262260

263261
if m == nil {
@@ -291,16 +289,16 @@ func TestGlideConfig_Import_MissingLockFile(t *testing.T) {
291289
h.Must(err)
292290
defer sm.Release()
293291

294-
h.TempDir(filepath.Join("src", testGlideProjectRoot))
295-
h.TempCopy(filepath.Join(testGlideProjectRoot, glideYamlName), "glide/glide.yaml")
296-
projectRoot := h.Path(testGlideProjectRoot)
292+
h.TempDir(filepath.Join("src", testProjectRoot))
293+
h.TempCopy(filepath.Join(testProjectRoot, glideYamlName), "glide/glide.yaml")
294+
projectRoot := h.Path(testProjectRoot)
297295

298296
g := newGlideImporter(ctx.Err, true, sm)
299297
if !g.HasDepMetadata(projectRoot) {
300298
t.Fatal("The glide importer should gracefully handle when only glide.yaml is present")
301299
}
302300

303-
m, l, err := g.Import(projectRoot, testGlideProjectRoot)
301+
m, l, err := g.Import(projectRoot, testProjectRoot)
304302
h.Must(err)
305303

306304
if m == nil {
@@ -340,7 +338,7 @@ func TestGlideConfig_Convert_WarnsForUnusedFields(t *testing.T) {
340338
Imports: []glidePackage{pkg},
341339
}
342340

343-
_, _, err = g.convert(testGlideProjectRoot)
341+
_, _, err = g.convert(testProjectRoot)
344342
if err != nil {
345343
t.Fatal(err)
346344
}

cmd/dep/godep_importer_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"github.com/pkg/errors"
1616
)
1717

18-
const testGodepProjectRoot = "github.com/golang/notexist"
18+
const testProjectRoot = "github.com/golang/notexist"
1919

2020
func TestGodepConfig_Convert(t *testing.T) {
2121
testCases := map[string]struct {
@@ -198,10 +198,10 @@ func TestGodepConfig_Import(t *testing.T) {
198198
cacheDir := "gps-repocache"
199199
h.TempDir(cacheDir)
200200
h.TempDir("src")
201-
h.TempDir(filepath.Join("src", testGodepProjectRoot))
202-
h.TempCopy(filepath.Join(testGodepProjectRoot, godepPath), "godep/Godeps.json")
201+
h.TempDir(filepath.Join("src", testProjectRoot))
202+
h.TempCopy(filepath.Join(testProjectRoot, godepPath), "godep/Godeps.json")
203203

204-
projectRoot := h.Path(testGodepProjectRoot)
204+
projectRoot := h.Path(testProjectRoot)
205205
sm, err := gps.NewSourceManager(h.Path(cacheDir))
206206
h.Must(err)
207207
defer sm.Release()
@@ -215,7 +215,7 @@ func TestGodepConfig_Import(t *testing.T) {
215215
t.Fatal("Expected the importer to detect godep configuration file")
216216
}
217217

218-
m, l, err := g.Import(projectRoot, testGodepProjectRoot)
218+
m, l, err := g.Import(projectRoot, testProjectRoot)
219219
h.Must(err)
220220

221221
if m == nil {
@@ -261,9 +261,9 @@ func TestGodepConfig_JsonLoad(t *testing.T) {
261261

262262
ctx := newTestContext(h)
263263

264-
h.TempCopy(filepath.Join(testGodepProjectRoot, godepPath), "godep/Godeps.json")
264+
h.TempCopy(filepath.Join(testProjectRoot, godepPath), "godep/Godeps.json")
265265

266-
projectRoot := h.Path(testGodepProjectRoot)
266+
projectRoot := h.Path(testProjectRoot)
267267

268268
g := newGodepImporter(ctx.Err, true, nil)
269269
err := g.load(projectRoot)

cmd/dep/root_analyzer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ func (a *rootAnalyzer) importManifestAndLock(dir string, pr gps.ProjectRoot, sup
7373
importers := []importer{
7474
newGlideImporter(logger, a.ctx.Verbose, a.sm),
7575
newGodepImporter(logger, a.ctx.Verbose, a.sm),
76+
newVndrImporter(logger, a.ctx.Verbose, a.sm),
7677
}
7778

7879
for _, i := range importers {

cmd/dep/testdata/harness_tests/init/vndr/case1/final/Gopkg.lock

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
[[constraint]]
3+
name = "github.com/sdboyer/deptestdos"
4+
version = "2.0.0"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2017 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package main
6+
7+
import (
8+
"fmt"
9+
10+
"github.com/sdboyer/deptestdos"
11+
)
12+
13+
func main() {
14+
var x deptestdos.Bar
15+
fmt.Println(x)
16+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Comment on its own line
2+
github.com/sdboyer/deptest 3f4c3bea144e112a69bbe5d8d01c1b09a544253f https://github.com/sdboyer/deptest.git
3+
github.com/sdboyer/deptestdos v2.0.0
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"commands": [
3+
["init", "-no-examples"]
4+
],
5+
"error-expected": "",
6+
"gopath-initial": {
7+
"github.com/sdboyer/deptest": "3f4c3bea144e112a69bbe5d8d01c1b09a544253f"
8+
},
9+
"vendor-final": [
10+
"github.com/sdboyer/deptest",
11+
"github.com/sdboyer/deptestdos"
12+
]
13+
}

cmd/dep/testdata/vndr/golden.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Detected vndr configuration file...
2+
Converting from vendor.conf...
3+
Using 3f4c3bea144e112a69bbe5d8d01c1b09a544253f as initial hint for imported dep github.com/sdboyer/deptest
4+
Trying v0.8.1 (3f4c3be) as initial lock for imported dep github.com/sdboyer/deptest
5+
Using ^2.0.0 as initial constraint for imported dep github.com/sdboyer/deptestdos
6+
Trying * (v2.0.0) as initial lock for imported dep github.com/sdboyer/deptestdos

cmd/dep/testdata/vndr/vendor.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
github.com/sdboyer/deptest 3f4c3bea144e112a69bbe5d8d01c1b09a544253f https://github.com/sdboyer/deptest.git # trailing comment
2+
# line comment
3+
4+
github.com/sdboyer/deptestdos v2.0.0 # trailing comment

0 commit comments

Comments
 (0)