This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
|
|
@ -0,0 +1,33 @@
|
|||
Demonstrate that we (wrongly) allow the expected file to be generated by a rule:
|
||||
|
||||
$ cat >dune-project <<EOF
|
||||
> (lang dune 3.18)
|
||||
> EOF
|
||||
|
||||
$ cat >dune <<EOF
|
||||
> (rule (write-file foo.expected "foo bar"))
|
||||
> (test
|
||||
> (name foo))
|
||||
> EOF
|
||||
|
||||
$ cat >foo.ml <<EOF
|
||||
> print_endline "baz";;
|
||||
> EOF
|
||||
|
||||
$ dune runtest
|
||||
File "foo.expected", line 1, characters 0-0:
|
||||
Error: Files _build/default/foo.expected and _build/default/foo.exe.output
|
||||
differ.
|
||||
[1]
|
||||
|
||||
The promotion wasn't registered
|
||||
|
||||
$ dune promotion list
|
||||
|
||||
Therefore, we keep re-running the test
|
||||
|
||||
$ dune runtest
|
||||
File "foo.expected", line 1, characters 0-0:
|
||||
Error: Files _build/default/foo.expected and _build/default/foo.exe.output
|
||||
differ.
|
||||
[1]
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
(rule
|
||||
(with-stdout-to generated.expected (echo "foo\nbar\n")))
|
||||
|
||||
(test
|
||||
(name generated)
|
||||
(modules generated))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.0)
|
||||
|
|
@ -0,0 +1 @@
|
|||
let () = print_endline "foo\nbaz"
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
$ dune runtest
|
||||
File "generated.expected", line 1, characters 0-0:
|
||||
Error: Files _build/default/generated.expected and
|
||||
_build/default/generated.exe.output differ.
|
||||
[1]
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(test
|
||||
(name modes)
|
||||
(modes byte native))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 3.0)
|
||||
|
|
@ -0,0 +1 @@
|
|||
testing multiple modes
|
||||
|
|
@ -0,0 +1 @@
|
|||
print_endline "testing multiple modes"
|
||||
|
|
@ -0,0 +1 @@
|
|||
$ dune runtest
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
(tests
|
||||
(names expect_test regular_test regular_test2))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.0)
|
||||
|
|
@ -0,0 +1 @@
|
|||
expect test
|
||||
|
|
@ -0,0 +1 @@
|
|||
let () = print_endline "expect test"
|
||||
|
|
@ -0,0 +1 @@
|
|||
let () = print_endline "regular test"
|
||||
|
|
@ -0,0 +1 @@
|
|||
let () = print_endline "regular test2"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
$ dune runtest
|
||||
regular test
|
||||
regular test2
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
(test
|
||||
(name singular))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.0)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
$ dune runtest
|
||||
singular test
|
||||
|
|
@ -0,0 +1 @@
|
|||
print_endline "singular test"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(test
|
||||
(name test)
|
||||
(action (run %{test})))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.0)
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
If there is an (action) field defined in a test stanza and dune-project sets
|
||||
(lang dune v) with v < 1.2, a warning is emitted:
|
||||
|
||||
$ dune runtest
|
||||
File "dune", line 3, characters 1-23:
|
||||
3 | (action (run %{test})))
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
Warning: 'action' is only available since version 1.2 of the dune language.
|
||||
Please update your dune-project file to have (lang dune 1.2).
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
(test
|
||||
(name my_test))
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
let show_argument n argument =
|
||||
Printf.printf "argv[%d] = %S\n" n argument
|
||||
|
||||
let () = Array.iteri show_argument Sys.argv
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.2)
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(tests
|
||||
(names my_test)
|
||||
(action (run %{test} arg1 arg2 arg3)))
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
argv[0] = "./my_test.exe"
|
||||
argv[1] = "arg1"
|
||||
argv[2] = "arg2"
|
||||
argv[3] = "arg3"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
let show_argument n argument =
|
||||
Printf.printf "argv[%d] = %S\n" n argument
|
||||
|
||||
let () = Array.iteri show_argument Sys.argv
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(tests
|
||||
(names my_test)
|
||||
(action (run %{test} arg1 arg2 arg3)))
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
let show_argument n argument =
|
||||
Printf.printf "argv[%d] = %S\n" n argument
|
||||
|
||||
let () = Array.iteri show_argument Sys.argv
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
If there is an (action) field, it is used to invoke to the executable (in both
|
||||
regular and expect modes:
|
||||
|
||||
$ dune build @explicit-regular/runtest
|
||||
argv[0] = "./my_test.exe"
|
||||
argv[1] = "arg1"
|
||||
argv[2] = "arg2"
|
||||
argv[3] = "arg3"
|
||||
|
||||
$ dune build @explicit-expect/runtest
|
||||
|
||||
If there is no field, the program is run with no arguments:
|
||||
|
||||
$ dune build @default/runtest
|
||||
argv[0] = "./my_test.exe"
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
Tests stanzas produce aliases with the executable names
|
||||
|
||||
$ cat > dune-project << EOF
|
||||
> (lang dune 3.17)
|
||||
> EOF
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (tests
|
||||
> (names a b))
|
||||
> EOF
|
||||
|
||||
$ cat > a.ml << EOF
|
||||
> let () = print_endline "a"
|
||||
> EOF
|
||||
|
||||
$ cat > b.ml << EOF
|
||||
> let () = print_endline "b"
|
||||
> EOF
|
||||
|
||||
$ dune build @runtest-a @runtest-b
|
||||
a
|
||||
b
|
||||
|
||||
Checking interaction with enabled_if
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (tests
|
||||
> (names a b)
|
||||
> (enabled_if false))
|
||||
> EOF
|
||||
|
||||
$ dune build @a @b
|
||||
Error: Alias "a" specified on the command line is empty.
|
||||
It is not defined in . or any of its descendants.
|
||||
Hint: did you mean all?
|
||||
Error: Alias "b" specified on the command line is empty.
|
||||
It is not defined in . or any of its descendants.
|
||||
[1]
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
For a test based on an .expected file, the deps field is ignored.
|
||||
This is visible when trying to build the `@all` alias. See #5950.
|
||||
|
||||
$ cat > dune-project << EOF
|
||||
> (lang dune 3.3)
|
||||
> EOF
|
||||
|
||||
$ cat > dune << EOF
|
||||
> (test
|
||||
> (name t)
|
||||
> (deps data.txt))
|
||||
> EOF
|
||||
|
||||
$ cat > t.ml << EOF
|
||||
> let () =
|
||||
> In_channel.with_open_bin "data.txt"
|
||||
> (fun ic -> print_string (In_channel.input_all ic))
|
||||
> EOF
|
||||
|
||||
$ cat > data.txt << EOF
|
||||
> data
|
||||
> EOF
|
||||
|
||||
$ cp data.txt t.expected
|
||||
|
||||
$ dune build t.exe.output
|
||||
Loading…
Add table
Add a link
Reference in a new issue