From e5ff770c9535ccf5db547c5c7c8777dea98daedc Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 27 Apr 2021 15:33:49 -0700 Subject: [PATCH] Add variant to dependency cycle errors Use moduleInfo.String() to print dependency cycle errors so they contain the variant. Test: Test_parallelVisit Change-Id: I2bddaa35c8abb57c42b4c424e861361a8813d588 --- context.go | 5 ++--- context_test.go | 14 +++++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/context.go b/context.go index ccf0409..f55b4b6 100644 --- a/context.go +++ b/context.go @@ -2158,9 +2158,8 @@ func cycleError(cycle []*moduleInfo) (errs []error) { for i := len(cycle) - 1; i >= 0; i-- { nextModule := cycle[i] errs = append(errs, &BlueprintError{ - Err: fmt.Errorf(" %q depends on %q", - curModule.Name(), - nextModule.Name()), + Err: fmt.Errorf(" %s depends on %s", + curModule, nextModule), Pos: curModule.pos, }) curModule = nextModule diff --git a/context_test.go b/context_test.go index 3e49a18..d91b89d 100644 --- a/context_test.go +++ b/context_test.go @@ -994,9 +994,9 @@ func Test_parallelVisit(t *testing.T) { }) want := []string{ `encountered dependency cycle`, - `"C" depends on "A"`, - `"A" depends on "B"`, - `"B" depends on "C"`, + `module "C" depends on module "A"`, + `module "A" depends on module "B"`, + `module "B" depends on module "C"`, } for i := range want { if len(errs) <= i { @@ -1030,8 +1030,8 @@ func Test_parallelVisit(t *testing.T) { }) want := []string{ `encountered dependency cycle`, - `"D" depends on "C"`, - `"C" depends on "D"`, + `module "D" depends on module "C"`, + `module "C" depends on module "D"`, } for i := range want { if len(errs) <= i { @@ -1067,8 +1067,8 @@ func Test_parallelVisit(t *testing.T) { }) want := []string{ `encountered dependency cycle`, - `"G" depends on "F"`, - `"F" depends on "G"`, + `module "G" depends on module "F"`, + `module "F" depends on module "G"`, } for i := range want { if len(errs) <= i {