diff options
author | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2015-03-31 00:50:32 +0900 |
---|---|---|
committer | Shinichiro Hamaji <shinichiro.hamaji@gmail.com> | 2015-03-31 00:50:32 +0900 |
commit | 0ec0770ef2d510ff23f2ea1d5405cee174ee0b5a (patch) | |
tree | 11dda40142e9e36f4574a8271260ff85304ec472 | |
parent | 5971b4bd57f43b742948cc5880c60d9439f40230 (diff) | |
download | kati-0ec0770ef2d510ff23f2ea1d5405cee174ee0b5a.tar.gz |
Fix the error message for "missing separator"
-rw-r--r-- | eval.go | 2 | ||||
-rw-r--r-- | log.go | 12 | ||||
-rwxr-xr-x | runtest.rb | 2 | ||||
-rw-r--r-- | test/err_missing_sep.mk | 4 |
4 files changed, 12 insertions, 8 deletions
@@ -161,7 +161,7 @@ func (ev *Evaluator) evalRawExpr(ast *RawExprAST) { result := ev.evalExpr(ast.expr) if result != "" { // TODO: Fix rule_in_var.mk. - fmt.Printf("%s:%d: *** missing separator. Stop.\n", ast.filename, ast.lineno) + Error(ast.filename, ast.lineno, "*** missing separator.") } } @@ -3,6 +3,7 @@ package main import ( "bytes" "fmt" + "os" ) func Log(f string, a ...interface{}) { @@ -18,11 +19,8 @@ func Warn(filename string, lineno int, f string, a ...interface{}) { fmt.Printf(f, a...) } -func Error(f string, a ...interface{}) { - var buf bytes.Buffer - buf.WriteString("error: ") - buf.WriteString(f) - buf.WriteByte('\n') - fmt.Printf(buf.String(), a...) - panic("") +func Error(filename string, lineno int, f string, a ...interface{}) { + f = fmt.Sprintf("%s:%d: %s\n", filename, lineno, f) + fmt.Printf(f, a...) + os.Exit(2) } @@ -53,6 +53,8 @@ Dir.glob('test/*.mk').sort.each do |mk| expected.gsub!(/[`'"]/, '"') expected.gsub!(/ (?:commands|recipe) for target /, ' commands for target ') + expected.gsub!(' (did you mean TAB instead of 8 spaces?)', '') + expected.gsub!(/\s+Stop\.$/, '') output.gsub!(/^\*kati\*.*\n/, '') File.open('out.make', 'w'){|ofile|ofile.print(expected)} diff --git a/test/err_missing_sep.mk b/test/err_missing_sep.mk index 257cc56..8d51450 100644 --- a/test/err_missing_sep.mk +++ b/test/err_missing_sep.mk @@ -1 +1,5 @@ +test: + foo + +bar |