(rule
 ((targets (stdout stderr))
  (action  (with-stdout-to stdout
            (with-stderr-to stderr
             (progn
              (system "echo toto")
              (system "echo titi >&2")))))))

(rule
 ((targets (both))
  (action  (with-outputs-to both
            (progn
             (system "echo toto")
             (system "echo titi >&2"))))))

(rule
 ((targets (stdout.expected))
  (action  (with-stdout-to ${@} (echo "toto\n")))))

(rule
 ((targets (stderr.expected))
  (action  (with-stdout-to ${@} (echo "titi\n")))))

(rule
 ((targets (both.expected))
  (action  (with-stdout-to ${@} (echo "toto\ntiti\n")))))

(alias
 ((name runtest)
  (deps (stdout stdout.expected))
  (action (run diff -uw  stdout.expected stdout))))

(alias
 ((name runtest)
  (deps (stderr stderr.expected))
  (action (run diff -uw stderr.expected stderr))))

(alias
 ((name runtest)
  (deps (both both.expected))
  (action (run diff -uw both.expected both))))

(alias
 ((name runtest)
  (action (ignore-stdout (echo "\
==========================
If you see this, something is wrong
")))))
