ocaml-re icon indicating copy to clipboard operation
ocaml-re copied to clipboard

re 1.12 broke tests in a dose3

Open RiderALT opened this issue 1 year ago • 5 comments
trafficstars

All tests associated with comparing versions through semver in dose3-7.0.0 are breaking. I think that arrays are incorrectly filled when analyzing the version by regular expression.

With ocaml-re 1.11 everything works fine.

And with ocaml-re 1.12: FAILED: Cases: 112 Tried: 112 Errors: 0 Failures: 21 Skip: 0 Todo: 0 Timeouts: 0.

One example of the output from the list of broken tests:

Failure: suite:5:test_decompose:5: =1.2.3 expected: 1.2.3-+ but got: 1.2.3

part of the src/versioning/semverNode.ml from dose3:

let rex =
  Pcre.regexp
    ("^\\s*[v=]*\\s*"
   (* optional version identifier *)
   ^ "([0-9]+|[xX*])(\\.([0-9]+|[xX*])?(\\.([0-9]+|[xX*])?)?)?"
    (* 3-dotted notation *)
    ^ "(?:-((?:[a-zA-Z0-9]+|[a-zA-Z0-9-])(?:\\.[a-zA-Z0-9]+|[a-zA-Z0-9-])*))?"
    ^ (* pre release *)
    "(?:\\+([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?\\s*$" (* build indentifier *)
    )

let sep_re = Pcre.regexp "\\."

let parse_raw_version version =
  try
    let parsed = Pcre.extract ~rex version in
    let pre = Pcre.split ~rex:sep_re parsed.(6) in
    let build = Pcre.split ~rex:sep_re parsed.(7) in
    (parsed.(1), parsed.(3), parsed.(5), pre, build)
  with Not_found ->
    raise
      (Invalid_argument
         (Printf.sprintf "%s: Parsing Error. Invalid Version" version))

RiderALT avatar Sep 07 '24 04:09 RiderALT

Thanks for the report. Can you give me an example of a version string from your test suite that parse_raw_version isn't parsing correctly?

rgrinberg avatar Sep 07 '24 11:09 rgrinberg

All versions from test_decompose, except 1.2.3-beta+build:

    [ ("v1.2.3", "1.2.3");
      ("=1.2.3", "1.2.3");
      ("v 1.2.3", "1.2.3");
      ("= 1.2.3", "1.2.3");
      (" v1.2.3", "1.2.3");
      (" =1.2.3", "1.2.3");
      (" v 1.2.3", "1.2.3");
      (" = 1.2.3", "1.2.3");
      ("1.2.3-0", "1.2.3-0");
      ("v1.2.3-1", "1.2.3-1");
      ("v1.2.3-beta", "1.2.3-beta");
      ("=1.2.3-beta", "1.2.3-beta");
      ("1.2.3-beta", "1.2.3-beta");
      ("1.2.3+build", "1.2.3+build");
      ("  v1.2.3+build", "1.2.3+build") ] )

https://gitlab.com/irill/dose3/-/blob/master/src/versioning/tests/tests.ml?ref_type=heads#L152

RiderALT avatar Sep 07 '24 14:09 RiderALT

While investigating a new build failure of dose3 in Debian, I bumped into this issue and we are affected.

Cross-reference: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1081360

glondu avatar Sep 11 '24 04:09 glondu

This was broken by #233. Re.Pcre.(split ~rex:(regexp "[.]")) "" now returns [""] when it should return the empty list.

vouillon avatar Sep 11 '24 09:09 vouillon

Hello, do we have any fix for this?

LocutusOfBorg avatar Sep 12 '24 19:09 LocutusOfBorg

This is not fixed in 1.13.3: https://github.com/ocaml/ocaml-re/issues/584

glondu avatar Aug 26 '25 08:08 glondu