vincent-hugot / qtest

Inline (Unit) Tests for OCaml
GNU General Public License v3.0
67 stars 8 forks source link

qtest parser confused by \\ #49

Closed rixed closed 6 years ago

rixed commented 6 years ago

Some tests are silently ignored. Exemple:

testme.ml:

let x = "\\"

(*$T
  false
*)

Makefile:

all: all_tests.opt
        ./all_tests.opt

%.cmx: %.ml
        ocamlfind ocamlopt -o $@ -c $<

all_tests.ml: testme.ml
        qtest --shuffle -o $@ extract $^

all_tests.opt: testme.cmx all_tests.ml
        ocamlfind ocamlopt -o $@ -package qcheck -linkpkg $^

output of make:

ocamlfind ocamlopt -o testme.cmx -c testme.ml
qtest --shuffle -o all_tests.ml extract testme.ml
!!! SHUFFLE is ON !!!
Target file: `all_tests.ml'. Extraction : `testme.ml' Warning: unterminated stringDone.
ocamlfind ocamlopt -o all_tests.opt -package qcheck -linkpkg testme.cmx all_tests.ml
./all_tests.opt
random seed: 296201411
Ran: 0 tests in: 0.00 seconds.                                        
SUCCESS

Notice the Warning: unterminated string.

Change the string in testme.ml by something innocuous and one gets the expected result:

ocamlfind ocamlopt -o testme.cmx -c testme.ml
qtest --shuffle -o all_tests.ml extract testme.ml
!!! SHUFFLE is ON !!!
Target file: `all_tests.ml'. Extraction : `testme.ml' Done.
ocamlfind ocamlopt -o all_tests.opt -package qcheck -linkpkg testme.cmx all_tests.ml
./all_tests.opt
random seed: 417805575
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Failure: >>testme.ml:4

testme.ml:4:  false
///////////////////////////////////////////////////////////////////////////////
Ran: 1 tests in: 0.00 seconds.                                        
FAILURE
make: *** [Makefile:2: all] Error 1
rixed commented 6 years ago

Forgot to say that I'm using qtest v2.7

c-cube commented 6 years ago

Can you take a look with master? 🙂

rixed commented 6 years ago

It seems to work now indeed. Thank you!