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

Commit e96a004

Browse files
authored
Merge pull request #1562 from speijnik/per-project-prune-fixes
Fix ignored per-project prune options (#1561)
2 parents 10d3175 + beab249 commit e96a004

File tree

3 files changed

+68
-3
lines changed

3 files changed

+68
-3
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ NEW FEATURES:
44

55
BUG FIXES:
66

7+
* Fix per-project prune option handling ([#1562](https://github.com/golang/dep/pull/1562))
8+
79
IMPROVEMENTS:
810

911
# v0.4.0

manifest.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -403,13 +403,13 @@ func fromRawPruneOptions(raw rawPruneOptions) gps.RootPruneOptions {
403403
pr := gps.ProjectRoot(p.Name)
404404
opts.ProjectOptions[pr] = gps.PruneNestedVendorDirs
405405

406-
if raw.UnusedPackages {
406+
if p.UnusedPackages {
407407
opts.ProjectOptions[pr] |= gps.PruneUnusedPackages
408408
}
409-
if raw.GoTests {
409+
if p.GoTests {
410410
opts.ProjectOptions[pr] |= gps.PruneGoTestFiles
411411
}
412-
if raw.NonGoFiles {
412+
if p.NonGoFiles {
413413
opts.ProjectOptions[pr] |= gps.PruneNonGoFiles
414414
}
415415
}

manifest_test.go

+63
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,69 @@ func TestValidateProjectRoots(t *testing.T) {
608608
}
609609
}
610610

611+
func TestFromRawPruneOptions(t *testing.T) {
612+
cases := []struct {
613+
name string
614+
rawPruneOptions rawPruneOptions
615+
wantOptions gps.RootPruneOptions
616+
}{
617+
{
618+
name: "global all options project no options",
619+
rawPruneOptions: rawPruneOptions{
620+
UnusedPackages: true,
621+
NonGoFiles: true,
622+
GoTests: true,
623+
Projects: []rawPruneProjectOptions{
624+
{
625+
Name: "github.com/golang/dep/gps",
626+
UnusedPackages: false,
627+
NonGoFiles: false,
628+
GoTests: false,
629+
},
630+
},
631+
},
632+
wantOptions: gps.RootPruneOptions{
633+
PruneOptions: 15,
634+
ProjectOptions: gps.PruneProjectOptions{
635+
"github.com/golang/dep/gps": 1,
636+
},
637+
},
638+
},
639+
{
640+
name: "global no options project all options",
641+
rawPruneOptions: rawPruneOptions{
642+
UnusedPackages: false,
643+
NonGoFiles: false,
644+
GoTests: false,
645+
Projects: []rawPruneProjectOptions{
646+
{
647+
Name: "github.com/golang/dep/gps",
648+
UnusedPackages: true,
649+
NonGoFiles: true,
650+
GoTests: true,
651+
},
652+
},
653+
},
654+
wantOptions: gps.RootPruneOptions{
655+
PruneOptions: 1,
656+
ProjectOptions: gps.PruneProjectOptions{
657+
"github.com/golang/dep/gps": 15,
658+
},
659+
},
660+
},
661+
}
662+
663+
for _, c := range cases {
664+
t.Run(c.name, func(t *testing.T) {
665+
opts := fromRawPruneOptions(c.rawPruneOptions)
666+
667+
if !reflect.DeepEqual(opts, c.wantOptions) {
668+
t.Fatalf("rawPruneOptions are not as expected:\n\t(GOT) %v\n\t(WNT) %v", opts, c.wantOptions)
669+
}
670+
})
671+
}
672+
}
673+
611674
func TestToRawPruneOptions(t *testing.T) {
612675
cases := []struct {
613676
name string

0 commit comments

Comments
 (0)