Handle empty output
diff --git a/eval.go b/eval.go
index a07be29..33fb00b 100644
--- a/eval.go
+++ b/eval.go
@@ -175,6 +175,11 @@
cmdLineno: ast.cmdLineno,
}
ev.curRule.parse(line)
+ // It seems rules with no outputs are siliently ignored.
+ if len(ev.curRule.outputs) == 0 {
+ ev.curRule = nil
+ return
+ }
var cmds []string
for _, cmd := range ast.cmds {
diff --git a/exec.go b/exec.go
index 140fd79..a1e58ac 100644
--- a/exec.go
+++ b/exec.go
@@ -1,7 +1,6 @@
package main
import (
- "errors"
"fmt"
"os"
"os/exec"
@@ -95,7 +94,7 @@
func (ex *Executor) exec(er *EvalResult, targets []string) error {
if len(er.rules) == 0 {
- return errors.New("no targets.")
+ ErrorNoLocation("*** No targets.")
}
for _, rule := range er.rules {
diff --git a/log.go b/log.go
index 6f39cc6..13d55cc 100644
--- a/log.go
+++ b/log.go
@@ -24,3 +24,9 @@
fmt.Printf(f, a...)
os.Exit(2)
}
+
+func ErrorNoLocation(f string, a ...interface{}) {
+ f = fmt.Sprintf("%s\n", f)
+ fmt.Printf(f, a...)
+ os.Exit(2)
+}
diff --git a/runtest.rb b/runtest.rb
index 3e0f1ae..aa8fc05 100755
--- a/runtest.rb
+++ b/runtest.rb
@@ -59,7 +59,8 @@
output += "\n=== FILES ===\n#{output_files * "\n"}\n"
end
- expected.gsub!(/^make\[.*\n/, '')
+ expected.gsub!(/^make\[\d+\]: (Entering|Leaving) directory.*\n/, '')
+ expected.gsub!(/^make\[\d+\]: /, '')
# Normalizations for old/new GNU make.
expected.gsub!(/[`'"]/, '"')
expected.gsub!(/ (?:commands|recipe) for target /,
diff --git a/test/empty_output.mk b/test/empty_output.mk
new file mode 100644
index 0000000..84e6717
--- /dev/null
+++ b/test/empty_output.mk
@@ -0,0 +1,5 @@
+:
+ echo FAIL
+
+test:
+ echo PASS
diff --git a/test/err_empty_output.mk b/test/err_empty_output.mk
new file mode 100644
index 0000000..93d5c8f
--- /dev/null
+++ b/test/err_empty_output.mk
@@ -0,0 +1,2 @@
+:
+ echo FAIL
diff --git a/test/warning.mk b/test/warning.mk
index ac61f15..340c3c2 100644
--- a/test/warning.mk
+++ b/test/warning.mk
@@ -1,3 +1,4 @@
$(warning foo)
test:
+ echo PASS