From 52727a199628c3166fe4ab90bc7ddd07c9e12677 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Thu, 29 Sep 2022 18:25:56 -0400 Subject: [PATCH] Nevermind this way is far better --- analyzer/table.go | 9 ++++++++- analyzer/test-common.go | 12 ------------ analyzer/type-section_test.go | 3 +-- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/analyzer/table.go b/analyzer/table.go index 9691de4..0d6e23c 100644 --- a/analyzer/table.go +++ b/analyzer/table.go @@ -1,5 +1,6 @@ package analyzer +import "os" import "path/filepath" // locator uniquely identifies a section in the section table. @@ -9,7 +10,13 @@ type locator struct { } func (where locator) ToString () (output string) { - output += where.modulePath + "." + where.name + cwd, _ := os.Getwd() + modulePath, err := filepath.Rel(cwd, where.modulePath) + if err != nil { + panic("cant get relative path: " + err.Error()) + } + + output += modulePath + "." + where.name return } diff --git a/analyzer/test-common.go b/analyzer/test-common.go index 616c6d1..ae186df 100644 --- a/analyzer/test-common.go +++ b/analyzer/test-common.go @@ -11,15 +11,3 @@ func checkTree (modulePath string, skim bool, correct string, test *testing.T) { table, err := Analyze(modulePath, skim) testCommon.CheckStrings(test, table, err, correct) } - -func resolvePath (path string) (resolved string) { - var err error - resolved, err = filepath.Abs(path) - if err != nil { - panic ( - "could not resolve path (check test cases!): " + - err.Error()) - } - resolved = filepath.Clean(resolved) - return -} diff --git a/analyzer/type-section_test.go b/analyzer/type-section_test.go index 52ee9af..1adb0c5 100644 --- a/analyzer/type-section_test.go +++ b/analyzer/type-section_test.go @@ -4,8 +4,7 @@ import "testing" func TestTypeSection (test *testing.T) { checkTree ("../tests/analyzer/typeSection", false, -` -typeSection ` + resolvePath("../tests/analyzer/typeSection.basicInt") + ` +`typeSection ../tests/analyzer/typeSection.basicInt type basic Int `, test) }