Skip to content

Commit

Permalink
better test
Browse files Browse the repository at this point in the history
Signed-off-by: Antonio Nuno Monteiro <anmonteiro@gmail.com>
  • Loading branch information
anmonteiro committed Oct 20, 2024
1 parent 056af19 commit 94ec620
Showing 1 changed file with 32 additions and 24 deletions.
56 changes: 32 additions & 24 deletions test/blackbox-tests/test-cases/pkg/gh10959.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,61 @@ Repro `dune exec --watch` crash with pkg management

$ . ./helpers.sh

$ cat >dune-project <<EOF
> (lang dune 3.13)
> (pin
> (url file://$PWD/_multiple)
> (package (name foo))
> (package (name bar)))
> (package
> (name main)
> (depends foo bar))
$ mkdir external_sources
$ cat >external_sources/dune-project <<EOF
> (lang dune 3.11)
> (package (name mypkg))
> EOF

$ cat >dune <<EOF
> (executable
> (name x))
$ cat >external_sources/dune <<EOF
> (library
> (public_name mypkg.lib)
> (name test_lib))
> EOF
$ cat >x.ml <<EOF
> let () = print_endline "hello"
$ cat >external_sources/test_lib.ml <<EOF
> let x = "hello"
> EOF

Now we set up a lock file with this package and then attempt to use it:

$ cat >dune-project <<EOF
> (lang dune 3.11)
> EOF

$ mkdir dune.lock
$ cat >dune.lock/lock.dune <<EOF
> (lang package 0.1)
> (repositories
> (complete true))
> EOF

$ cat >dune.lock/test.pkg <<EOF
$ cat >dune.lock/mypkg.pkg <<EOF
> (version 0.0.1)
> (source (copy $PWD/external_sources))
> (build
> (system "echo building test"))
> (run dune build --release --promote-install-file=true . @install))
> EOF

$ cat >dune <<EOF
> (dirs (:standard \ external_sources))
> (executable
> (name x)
> (libraries mypkg.lib))
> EOF

$ cat >x.ml <<EOF
> let () = print_endline Test_lib.x
> EOF

$ dune exec -w ./x.exe > output.log 2>&1 &
$ PID=$!

$ TIME_WAITED=0
$ MAX_WAIT_TIME=30
$ MAX_WAIT_TIME=20
$ SLEEP_INTERVAL=1
$ while [ $(cat output.log | wc -l) -lt 3 ] && [ "$TIME_WAITED" -lt "$MAX_WAIT_TIME" ]; do
$ while [ $(cat output.log | wc -l) -lt 2 ] && [ "$TIME_WAITED" -lt "$MAX_WAIT_TIME" ]; do
> sleep 0.1
> TIME_WAITED=$((TIME_WAITED + SLEEP_INTERVAL))
> done
$ echo $TIME_WAITED
6

$ cat output.log | sort
Success, waiting for filesystem changes...
building test
hello
$ kill $PID

0 comments on commit 94ec620

Please sign in to comment.