(executables
 (names test_junit test_crash test_long)
 (modules test_junit test_crash test_long)
 (libraries alcotest))

(executable
 (name normalise)
 (modules normalise)
 (libraries re unix))

; The location of failures is off in the other e2e tests.

(env
 (_
  (env-vars
   (ALCOTEST_SOURCE_CODE_POSITION true))))

(rule
 (with-stdout-to
  report.processed
  (run ./normalise.exe %{exe:test_junit.exe})))

(rule
 (with-stdout-to
  crash.processed
  (run ./normalise.exe %{exe:test_crash.exe})))

(rule
 (alias runtest)
 (package alcotest)
 (action
  (diff report.expected report.processed)))

(rule
 (alias runtest)
 (package alcotest)
 (action
  (diff crash.expected crash.processed)))

(rule
 (with-stdout-to
  long.processed
  (run ./normalise.exe %{exe:test_long.exe} --sizes)))

(rule
 (alias runtest)
 (package alcotest)
 (action
  (diff long.expected long.processed)))

; Windows has no [fork].

(executable
 (name test_fork)
 (modules test_fork)
 (enabled_if
  (<> %{os_type} Win32))
 (libraries alcotest unix))

(rule
 (target fork.processed)
 (enabled_if
  (<> %{os_type} Win32))
 (action
  (with-stdout-to
   %{target}
   (run ./normalise.exe %{exe:test_fork.exe}))))

(rule
 (alias runtest)
 (package alcotest)
 (enabled_if
  (<> %{os_type} Win32))
 (action
  (diff fork.expected fork.processed)))
