Commit 9456b795 authored by POTTIER Francois's avatar POTTIER Francois

Remove a bashism in [make test].

parent 2e3c2441
Pipeline #210716 passed with stages
in 1 minute
......@@ -2,150 +2,170 @@
;; Instead, edit [test.ml] and run [make depend].
(rule
(with-stdout-to merged01.out
(with-stdout-to merged01.out.tmp
(with-stderr-to merged01.err
(with-accepted-exit-codes 0
(system
"set -o pipefail && \
%{bin:menhir} %{dep:parser.mly} \
"%{bin:menhir} %{dep:parser.mly} \
--merge-errors %{dep:lhs01.messages} \
--merge-errors %{dep:rhs01.messages} \
| sed -e '/^##/d'")))))
--merge-errors %{dep:rhs01.messages}")))))
(rule
(with-stdin-from merged01.out.tmp
(with-stdout-to merged01.out (system "sed -e '/^##/d'"))))
(rule (alias test) (action (diff merged01.xout merged01.out)))
(rule (alias test) (action (diff merged01.xerr merged01.err)))
(rule
(with-stdout-to merged02.out
(with-stdout-to merged02.out.tmp
(with-stderr-to merged02.err
(with-accepted-exit-codes 0
(system
"set -o pipefail && \
%{bin:menhir} %{dep:parser.mly} \
"%{bin:menhir} %{dep:parser.mly} \
--merge-errors %{dep:lhs02.messages} \
--merge-errors %{dep:rhs02.messages} \
| sed -e '/^##/d'")))))
--merge-errors %{dep:rhs02.messages}")))))
(rule
(with-stdin-from merged02.out.tmp
(with-stdout-to merged02.out (system "sed -e '/^##/d'"))))
(rule (alias test) (action (diff merged02.xout merged02.out)))
(rule (alias test) (action (diff merged02.xerr merged02.err)))
(rule
(with-stdout-to merged03.out
(with-stdout-to merged03.out.tmp
(with-stderr-to merged03.err
(with-accepted-exit-codes 0
(system
"set -o pipefail && \
%{bin:menhir} %{dep:parser.mly} \
"%{bin:menhir} %{dep:parser.mly} \
--merge-errors %{dep:lhs03.messages} \
--merge-errors %{dep:rhs03.messages} \
| sed -e '/^##/d'")))))
--merge-errors %{dep:rhs03.messages}")))))
(rule
(with-stdin-from merged03.out.tmp
(with-stdout-to merged03.out (system "sed -e '/^##/d'"))))
(rule (alias test) (action (diff merged03.xout merged03.out)))
(rule (alias test) (action (diff merged03.xerr merged03.err)))
(rule
(with-stdout-to merged04.out
(with-stdout-to merged04.out.tmp
(with-stderr-to merged04.err
(with-accepted-exit-codes 0
(system
"set -o pipefail && \
%{bin:menhir} %{dep:parser.mly} \
"%{bin:menhir} %{dep:parser.mly} \
--merge-errors %{dep:lhs04.messages} \
--merge-errors %{dep:rhs04.messages} \
| sed -e '/^##/d'")))))
--merge-errors %{dep:rhs04.messages}")))))
(rule
(with-stdin-from merged04.out.tmp
(with-stdout-to merged04.out (system "sed -e '/^##/d'"))))
(rule (alias test) (action (diff merged04.xout merged04.out)))
(rule (alias test) (action (diff merged04.xerr merged04.err)))
(rule
(with-stdout-to merged05.out
(with-stdout-to merged05.out.tmp
(with-stderr-to merged05.err
(with-accepted-exit-codes 0
(system
"set -o pipefail && \
%{bin:menhir} %{dep:parser.mly} \
"%{bin:menhir} %{dep:parser.mly} \
--merge-errors %{dep:lhs05.messages} \
--merge-errors %{dep:rhs05.messages} \
| sed -e '/^##/d'")))))
--merge-errors %{dep:rhs05.messages}")))))
(rule
(with-stdin-from merged05.out.tmp
(with-stdout-to merged05.out (system "sed -e '/^##/d'"))))
(rule (alias test) (action (diff merged05.xout merged05.out)))
(rule (alias test) (action (diff merged05.xerr merged05.err)))
(rule
(with-stdout-to merged06.out
(with-stdout-to merged06.out.tmp
(with-stderr-to merged06.err
(with-accepted-exit-codes 0
(system
"set -o pipefail && \
%{bin:menhir} %{dep:parser.mly} \
"%{bin:menhir} %{dep:parser.mly} \
--merge-errors %{dep:lhs06.messages} \
--merge-errors %{dep:rhs06.messages} \
| sed -e '/^##/d'")))))
--merge-errors %{dep:rhs06.messages}")))))
(rule
(with-stdin-from merged06.out.tmp
(with-stdout-to merged06.out (system "sed -e '/^##/d'"))))
(rule (alias test) (action (diff merged06.xout merged06.out)))
(rule (alias test) (action (diff merged06.xerr merged06.err)))
(rule
(with-stdout-to merged07.out
(with-stdout-to merged07.out.tmp
(with-stderr-to merged07.err
(with-accepted-exit-codes 0
(system
"set -o pipefail && \
%{bin:menhir} %{dep:parser.mly} \
"%{bin:menhir} %{dep:parser.mly} \
--merge-errors %{dep:lhs07.messages} \
--merge-errors %{dep:rhs07.messages} \
| sed -e '/^##/d'")))))
--merge-errors %{dep:rhs07.messages}")))))
(rule
(with-stdin-from merged07.out.tmp
(with-stdout-to merged07.out (system "sed -e '/^##/d'"))))
(rule (alias test) (action (diff merged07.xout merged07.out)))
(rule (alias test) (action (diff merged07.xerr merged07.err)))
(rule
(with-stdout-to merged08.out
(with-stdout-to merged08.out.tmp
(with-stderr-to merged08.err
(with-accepted-exit-codes 0
(system
"set -o pipefail && \
%{bin:menhir} %{dep:parser.mly} \
"%{bin:menhir} %{dep:parser.mly} \
--merge-errors %{dep:lhs08.messages} \
--merge-errors %{dep:rhs08.messages} \
| sed -e '/^##/d'")))))
--merge-errors %{dep:rhs08.messages}")))))
(rule
(with-stdin-from merged08.out.tmp
(with-stdout-to merged08.out (system "sed -e '/^##/d'"))))
(rule (alias test) (action (diff merged08.xout merged08.out)))
(rule (alias test) (action (diff merged08.xerr merged08.err)))
(rule
(with-stdout-to merged09.out
(with-stdout-to merged09.out.tmp
(with-stderr-to merged09.err
(with-accepted-exit-codes 0
(system
"set -o pipefail && \
%{bin:menhir} %{dep:parser.mly} \
"%{bin:menhir} %{dep:parser.mly} \
--merge-errors %{dep:lhs09.messages} \
--merge-errors %{dep:rhs09.messages} \
| sed -e '/^##/d'")))))
--merge-errors %{dep:rhs09.messages}")))))
(rule
(with-stdin-from merged09.out.tmp
(with-stdout-to merged09.out (system "sed -e '/^##/d'"))))
(rule (alias test) (action (diff merged09.xout merged09.out)))
(rule (alias test) (action (diff merged09.xerr merged09.err)))
(rule
(with-stdout-to merged10.out
(with-stdout-to merged10.out.tmp
(with-stderr-to merged10.err
(with-accepted-exit-codes 0
(system
"set -o pipefail && \
%{bin:menhir} %{dep:parser.mly} \
"%{bin:menhir} %{dep:parser.mly} \
--merge-errors %{dep:lhs10.messages} \
--merge-errors %{dep:rhs10.messages} \
| sed -e '/^##/d'")))))
--merge-errors %{dep:rhs10.messages}")))))
(rule
(with-stdin-from merged10.out.tmp
(with-stdout-to merged10.out (system "sed -e '/^##/d'"))))
(rule (alias test) (action (diff merged10.xout merged10.out)))
......
......@@ -47,6 +47,11 @@ let system command =
let system format =
ksprintf system format
(* Redirecting the input channel of an action. *)
let redirect_stdin filename action =
L[A"with-stdin-from"; A filename; action]
(* Redirecting the output channels of an action towards a file. *)
(* At the time of writing (2.7.1), dune has a bug that causes it to send
......
......@@ -296,24 +296,30 @@ let good_or_bad () =
(* The number of tests is currently hardcoded here, and they have a fixed
naming convention. *)
(* We wish to we pipe Menhir's output through sed in order to remove the
auto-generated comments. We need this process to fail if Menhir fails.
We could use a pipe and [set -o pipefail], but this is specific to
bash. Instead, we go through a temporary file. *)
let n = 10
let merge mly lhs rhs out err xout xerr =
let tmp = sprintf "%s.tmp" out in
print (rule [] [] (
redirect_stdout out (
redirect_stdout tmp (
redirect_stderr err (
not_expecting_failure (
(* We must use a [system] action because we pipe Menhir's output through
sed in order to remove the auto-generated comments. [set -o pipefail]
forces the pipeline to fail if Menhir fails. *)
system
"set -o pipefail && \\\n \
%%{bin:menhir} %%{dep:%s} \\\n \
--merge-errors %%{dep:%s} \\\n \
"%%{bin:menhir} %%{dep:%s} \\\n \
--merge-errors %%{dep:%s} \\\n \
| sed -e '/^##/d'"
--merge-errors %%{dep:%s}"
mly lhs rhs
)))));
print (rule [] [] (
redirect_stdin tmp (
redirect_stdout out (
system "sed -e '/^##/d'"
))));
print (phony "test" (diff xout out));
print (phony "test" (diff xerr err))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment