diff --git a/go/tests/rc/rc.go b/go/tests/rc/rc.go index 8baefb16..02c76e40 100644 --- a/go/tests/rc/rc.go +++ b/go/tests/rc/rc.go @@ -282,7 +282,7 @@ func loadProgram(path string, load loadedSource) error { for _, v := range l.relImports { if load[v.name] == nil { - newPath, _ := filepath.Abs(path + "/" + v.name) + newPath := filepath.Clean(path + "/" + v.name) err = loadProgram(newPath, load) if err != nil { return err @@ -454,11 +454,7 @@ func isAllowed(function *element, path string, load loadedSource, walked map[ast continue } - newPath, err := filepath.Abs(path + "/" + importRelPath.name) - - if err != nil { - panic(err) - } + newPath := filepath.Clean(path + "/" + importRelPath.name) newEl := newElement(fun.name) allowedSel := isAllowed(newEl, newPath, load, walked, info) if !allowedSel { diff --git a/go/tests/rc/rc_test.go b/go/tests/rc/rc_test.go index d7f392aa..a7c3b4a3 100644 --- a/go/tests/rc/rc_test.go +++ b/go/tests/rc/rc_test.go @@ -2,7 +2,6 @@ package main import ( "fmt" - "runtime" "strings" "testing" @@ -106,16 +105,31 @@ Cheating: Ok Cheating: Ok +`, + `test/testingWrapping.go`: `Parsing: + Ok +Cheating: + TYPE: NAME: LOCATION: + illegal-call len tests/utilDepth2/wrapper.go:4:9 + illegal-definition LenWrapper tests/utilDepth2/wrapper.go:3:1 + illegal-access util2.LenWrapper tests/util/util.go:10:9 + illegal-definition LenWrapperU tests/util/util.go:9:1 + illegal-access util.LenWrapperU tests/testingWrapping.go:8:9 + illegal-definition Length tests/testingWrapping.go:7:1 +`, + `test/testingWrapping.go len`: `Parsing: + Ok +Cheating: + Ok `, } - _, filename, _, _ := runtime.Caller(1) - fmt.Println("Filename:", filename) Compare(t, argsAndSolution) } func Compare(t *testing.T, argsAndSol map[string]string) { for args, sol := range argsAndSol { - out, err := z01.MainOut("../rc", strings.Split(args, " ")...) + a := strings.Split(args, " ") + out, err := z01.MainOut("../rc", a...) if EqualResult(out, sol) && err != nil && EqualResult(err.Error(), sol) { fmt.Println(args, "\nError:", err) fmt.Println("Solution:", sol) @@ -133,3 +147,12 @@ func EqualResult(out, sol string) bool { } return false } + +func ExtractFile(args []string) string { + for _, v := range args { + if strings.HasSuffix(v, ".go") { + return v + } + } + return "" +}