Browse Source

Format error message and fix prevent errors

pull/646/head
Augusto 5 years ago committed by xpetit
parent
commit
3e7ac1e1cb
  1. 14
      rc/rc.go
  2. 4
      rc/rc_test.go

14
rc/rc.go

@ -99,7 +99,7 @@ func main() {
filename := goFile(flag.Args()) filename := goFile(flag.Args())
if filename == "" { if filename == "" {
fmt.Println("No file to analyse") fmt.Println("\tNo file to analyse")
os.Exit(1) os.Exit(1)
} }
@ -108,7 +108,7 @@ func main() {
err := parseArgs(flag.Args(), allowBuiltin, casting) err := parseArgs(flag.Args(), allowBuiltin, casting)
if err != nil { if err != nil {
fmt.Println(err) fmt.Printf("\t%s\n", err)
os.Exit(1) os.Exit(1)
} }
@ -119,7 +119,7 @@ func main() {
err = loadProgram(currentPath, load) err = loadProgram(currentPath, load)
if err != nil { if err != nil {
fmt.Println(err) fmt.Printf("\t%s\n", err)
os.Exit(1) os.Exit(1)
} }
fmt.Println("\tOk") fmt.Println("\tOk")
@ -609,11 +609,15 @@ func parseArgs(toAllow []string, builtins bool, casting bool) error {
funcName = filepath.Base(v) funcName = filepath.Base(v)
spl := strings.Split(funcName, ".") spl := strings.Split(funcName, ".")
path = path + "/" + spl[0] path = path + "/" + spl[0]
funcName = spl[1] if len(spl) > 1 {
funcName = spl[1]
}
} else if strings.ContainsRune(v, '.') { } else if strings.ContainsRune(v, '.') {
spl := strings.Split(v, ".") spl := strings.Split(v, ".")
path = spl[0] path = spl[0]
funcName = spl[1] if len(spl) > 1 {
funcName = spl[1]
}
} else { } else {
path = "builtin" path = "builtin"
funcName = v funcName = v

4
rc/rc_test.go

@ -122,10 +122,10 @@ Cheating:
Cheating: Cheating:
Ok Ok
`, `,
`tests/empty/empty len`: `No file to analyse `tests/empty/empty len`: ` No file to analyse
`, `,
`tests/empty/empty.go`: `Parsing: `tests/empty/empty.go`: `Parsing:
tests/empty/empty.go:1:1: expected ';', found 'EOF' (and 2 more errors) tests/empty/empty.go:1:1: expected ';', found 'EOF' (and 2 more errors)
`, `,
} }
Compare(t, argsAndSolution) Compare(t, argsAndSolution)

Loading…
Cancel
Save