This commit is contained in:
swrup 2025-11-11 02:07:51 +01:00
parent aa2ff7b2f0
commit 2f3113f55d
11742 changed files with 1223940 additions and 0 deletions

View file

@ -0,0 +1,33 @@
Cinaps should offer all promotions at once
$ cat > dune-project <<EOF
> (lang dune 3.8)
> (using cinaps 1.3)
> EOF
$ cat > t1.ml <<"EOF"
> (*$ print_endline "\nhello" *)
> (*$*)
> let x = 1
> EOF
$ cat > t2.ml <<"EOF"
> (*$ print_endline "\nhello" *)
> (*$*)
> let x = 1
> EOF
$ cat >dune <<EOF
> (cinaps
> (files *.ml)
> (alias cinaps))
> EOF
$ dune build @cinaps
File "t1.ml", line 1, characters 0-0:
Error: Files _build/default/t1.ml and _build/default/t1.ml.cinaps-corrected
differ.
File "t2.ml", line 1, characters 0-0:
Error: Files _build/default/t2.ml and _build/default/t2.ml.cinaps-corrected
differ.
[1]

View file

@ -0,0 +1,17 @@
Custom alias for the cinaps
$ cat > dune-project <<EOF
> (lang dune 3.7)
> (using cinaps 1.2)
> EOF
$ cat > dune <<EOF
> (cinaps
> (files foo.ml)
> (alias foo))
> EOF
$ touch foo.ml
$ dune build @foo --display short 2>&1 | grep alias
cinaps alias foo

View file

@ -0,0 +1,4 @@
(cram
(applies_to :whole_subtree)
(deps
(package cinaps)))

View file

@ -0,0 +1,29 @@
cinaps doesn't work with (include_subdirs unqualified)
$ cat > dune-project <<EOF
> (lang dune 2.3)
> (using cinaps 1.0)
> EOF
$ cat >dune <<EOF
> (include_subdirs unqualified)
> (executable (name test))
> EOF
$ mkdir sub
$ cat >sub/dune <<EOF
> (cinaps (files test.ml))
> EOF
$ cat >sub/test.ml <<EOF
> (*$ print_endline "\nhello" *)
> (*$*)
> let x = 1
> EOF
$ dune runtest --diff-command diff 2>&1 | sed -E 's/[^ ]+sh/\$sh/'
File "sub/test.ml", line 1, characters 0-0:
2,3c2
< (*)
< let x = 1
---
> hello

View file

@ -0,0 +1,47 @@
Link-time flags for running cinaps
$ cat > dune-project <<EOF
> (lang dune 3.8)
> (using cinaps 1.3)
> EOF
$ cat > dune <<EOF
> (cinaps
> (files *.ml)
> (link_flags -linkall))
> EOF
$ touch test.ml
$ dune build --verbose @cinaps 2>&1 | sed -n 's#.*/cinaps.exe.*\(-linkall\).*#\1#p'
-linkall
Check that the version guard is correct.
$ cat > dune-project <<EOF
> (lang dune 3.7)
> (using cinaps 1.3)
> EOF
$ dune build @cinaps
File "dune-project", line 2, characters 14-17:
2 | (using cinaps 1.3)
^^^
Error: Version 1.3 of the cinaps extension is not supported until version 3.8
of the dune language.
Supported versions of this extension in version 3.7 of the dune language:
- 1.0 to 1.2
[1]
$ cat > dune-project <<EOF
> (lang dune 3.8)
> (using cinaps 1.2)
> EOF
$ dune build @cinaps
File "dune", line 3, characters 1-22:
3 | (link_flags -linkall))
^^^^^^^^^^^^^^^^^^^^^
Error: 'link_flags' is only available since version 1.3 of the cinaps
extension. Please update your dune-project file to have (using cinaps 1.3).
[1]

View file

@ -0,0 +1,29 @@
Multiple cinaps stanzas in the same dune file
$ cat > dune-project <<EOF
> (lang dune 2.8)
> (using cinaps 1.0)
> EOF
$ cat > dune <<EOF
> (cinaps (files *.ml))
> (cinaps (files *.mli))
> EOF
$ touch x.ml x.mli
$ dune runtest --diff-command diff 2>&1
$ touch foo.ml
$ cat > dune <<EOF
> (cinaps (files foo.ml))
> (cinaps (files *oo.ml))
> EOF
$ dune runtest --diff-command diff 2>&1
Error: Multiple rules generated for
_build/default/.cinaps.f0d91a31/cinaps.ml-gen:
- dune:1
- dune:2
-> required by alias cinaps in dune:1
-> required by alias runtest
[1]

View file

@ -0,0 +1,30 @@
Runtime dependencies for running cinaps
$ cat > dune-project <<EOF
> (lang dune 3.5)
> (using cinaps 1.1)
> EOF
$ cat > foo <<EOF
> hello world
> EOF
$ cat > dune <<EOF
> (cinaps
> (files *.ml)
> (runtime_deps foo))
> EOF
$ cat > test.ml <<EOF
> (*$ let f = open_in "foo" in print_endline (input_line f); close_in f *)
> (*$*)
> EOF
$ dune build @cinaps --auto-promote
File "test.ml", line 1, characters 0-0:
Error: Files _build/default/test.ml and
_build/default/test.ml.cinaps-corrected differ.
Promoting _build/default/test.ml.cinaps-corrected to test.ml.
[1]
$ cat test.ml
(*$ let f = open_in "foo" in print_endline (input_line f); close_in f *)hello world

View file

@ -0,0 +1,45 @@
Test of cinaps integration
$ cat > dune-project <<EOF
> (lang dune 1.11)
> (using cinaps 1.0)
> EOF
$ cat > dune <<EOF
> (cinaps (files *.ml))
> EOF
$ cat > test.ml <<"EOF"
> (*$ print_endline "\nhello" *)
> (*$*)
> let x = 1
> EOF
The cinaps actions should be attached to the runtest alias:
$ dune runtest --diff-command diff 2>&1 | sed -E 's/[^ ]+sh/\$sh/'
File "test.ml", line 1, characters 0-0:
1a2
> hello
but also to the cinaps alias:
$ dune build @cinaps --diff-command diff 2>&1 | sed -E 's/[^ ]+sh/\$sh/'
File "test.ml", line 1, characters 0-0:
1a2
> hello
The cinaps stanza offers a promotion workflow:
$ dune runtest --auto-promote
File "test.ml", line 1, characters 0-0:
Error: Files _build/default/test.ml and
_build/default/test.ml.cinaps-corrected differ.
Promoting _build/default/test.ml.cinaps-corrected to test.ml.
[1]
$ cat test.ml
(*$ print_endline "\nhello" *)
hello
(*$*)
let x = 1