Nevermind this way is far better

This commit is contained in:
Sasha Koshka 2022-09-29 18:25:56 -04:00
parent 8ead560bfb
commit 52727a1996
3 changed files with 9 additions and 15 deletions

View File

@ -1,5 +1,6 @@
package analyzer package analyzer
import "os"
import "path/filepath" import "path/filepath"
// locator uniquely identifies a section in the section table. // locator uniquely identifies a section in the section table.
@ -9,7 +10,13 @@ type locator struct {
} }
func (where locator) ToString () (output string) { 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 return
} }

View File

@ -11,15 +11,3 @@ func checkTree (modulePath string, skim bool, correct string, test *testing.T) {
table, err := Analyze(modulePath, skim) table, err := Analyze(modulePath, skim)
testCommon.CheckStrings(test, table, err, correct) 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
}

View File

@ -4,8 +4,7 @@ import "testing"
func TestTypeSection (test *testing.T) { func TestTypeSection (test *testing.T) {
checkTree ("../tests/analyzer/typeSection", false, checkTree ("../tests/analyzer/typeSection", false,
` `typeSection ../tests/analyzer/typeSection.basicInt
typeSection ` + resolvePath("../tests/analyzer/typeSection.basicInt") + `
type basic Int type basic Int
`, test) `, test)
} }