Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re 1.12 broke tests in a dose3 #411

Closed
RiderALT opened this issue Sep 7, 2024 · 5 comments · Fixed by #538
Closed

re 1.12 broke tests in a dose3 #411

RiderALT opened this issue Sep 7, 2024 · 5 comments · Fixed by #538
Labels

Comments

@RiderALT
Copy link

RiderALT commented Sep 7, 2024

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))
@rgrinberg
Copy link
Member

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 rgrinberg added the pcre label Sep 7, 2024
@RiderALT
Copy link
Author

RiderALT commented Sep 7, 2024

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

rgrinberg added a commit that referenced this issue Sep 7, 2024
@glondu
Copy link
Contributor

glondu commented Sep 11, 2024

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

@vouillon
Copy link
Member

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

@LocutusOfBorg
Copy link

Hello, do we have any fix for this?

vouillon added a commit that referenced this issue Oct 18, 2024
An occurrence of the delimiter at the beginning or at the end of the
string is ignored.

Fixes #288, fixes #411.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants