unicode

Branch: main

Switch branches or tags

Branch: main
Go to file t

413 files indexed

History
Code

tools/release/release_wbtest.mbt
1///|2test "release versions use stable semantic version syntax" {3  validate_release_version("0.4.0")4  validate_release_version("10.20.30")5  for invalid in ["1.2", "1.2.3-rc.1", "01.2.3", "v1.2.3"] {6    try validate_release_version(invalid) catch {7      ReleaseError(_) => ()8    } noraise {9      _ => fail("expected invalid release version: \{invalid}")10    }11  }12}1314///|15test "publish dry-run accepts the known false failure" {16  let output =17    #|Server status: 202 Accepted, detail: Dry run completed successfully. No changes were made. The dry-run was made for package moonbit-community/unicode-data version 0.4.0.18    #|Error: `moon publish` failed19  assert_true(20    publish_dry_run_succeeded(0, "", "moonbit-community/unicode-data", "0.4.0"),21  )22  assert_true(23    publish_dry_run_succeeded(24      255, output, "moonbit-community/unicode-data", "0.4.0",25    ),26  )27  assert_true(28    publish_dry_run_succeeded(29      -1, output, "moonbit-community/unicode-data", "0.4.0",30    ),31  )32  assert_false(33    publish_dry_run_succeeded(34      1, output, "moonbit-community/unicode-data", "0.4.0",35    ),36  )37  assert_false(38    publish_dry_run_succeeded(39      255, output, "moonbit-community/unicode-idna", "0.4.0",40    ),41  )42  assert_false(43    publish_dry_run_succeeded(44      255, "Server status: 500 Internal Server Error", "moonbit-community/unicode-data",45      "0.4.0",46    ),47  )48}4950///|51test "release version comes from consistent published manifests" {52  let versions = [53    ("ucd/moon.mod", "0.4.0"),54    ("punycode/moon.mod", "0.4.0"),55    ("unicode/moon.mod", "0.4.0"),56  ]57  inspect(release_version_from_manifests(versions), content="0.4.0")58  try59    release_version_from_manifests([60      ("ucd/moon.mod", "0.4.1"),61      ("unicode/moon.mod", "0.4.0"),62    ])63  catch {64    ReleaseError(message) =>65      inspect(66        message,67        content="Published module versions are inconsistent: ucd/moon.mod has 0.4.1, expected 0.4.0 from unicode/moon.mod",68      )69  } noraise {70    _ => fail("expected inconsistent published versions to fail")71  }72  try release_version_from_manifests([("ucd/moon.mod", "0.4.0")]) catch {73    ReleaseError(message) =>74      inspect(75        message,76        content="Published manifests do not contain the umbrella manifest unicode/moon.mod",77      )78  } noraise {79    _ => fail("expected a missing root manifest to fail")80  }81}8283///|84test "manifest version is read and replaced without reformatting" {85  let source =86    #|name = "moonbit-community/example"87    #|88    #|version = "0.3.4"89    #|90  inspect(manifest_version(source, "unicode/moon.mod"), content="0.3.4")91  inspect(92    replace_manifest_version(source, "unicode/moon.mod", "0.4.0"),93    content=(94      #|name = "moonbit-community/example"95      #|96      #|version = "0.4.0"97      #|98    ),99  )100}101102///|103test "manifest version accepts CRLF line endings" {104  let source = "name = \"moonbit-community/example\"\r\n\r\nversion = \"0.3.4\"\r\n"105  inspect(manifest_version(source, "unicode/moon.mod"), content="0.3.4")106  inspect(107    replace_manifest_version(source, "unicode/moon.mod", "0.4.0"),108    content="name = \"moonbit-community/example\"\r\n\r\nversion = \"0.4.0\"\r\n",109  )110}111112///|113test "manifest version declarations must be unique" {114  try115    manifest_version(116      "version = \"0.3.4\"\nversion = \"0.4.0\"\n", "ucd/moon.mod",117    )118  catch {119    ReleaseError(message) =>120      inspect(121        message,122        content="ucd/moon.mod contains more than one top-level version declaration",123      )124  } noraise {125    _ => fail("expected duplicate version declaration to fail")126  }127  try128    manifest_version(129      "name = \"moonbit-community/unicode-data\"\n", "ucd/moon.mod",130    )131  catch {132    ReleaseError(message) =>133      inspect(134        message,135        content="ucd/moon.mod does not contain a top-level version = \"...\" declaration",136      )137  } noraise {138    _ => fail("expected missing version declaration to fail")139  }140}141142///|143test "published modules follow dependency order" {144  guard published_modules145    is [146      ucd,147      punycode,148      bidi,149      segmentation,150      normalization,151      casefold,152      idna,153      unicode,154    ] else {155    fail("expected eight published modules")156  }157  assert_false(ucd.requires_published_dependencies)158  assert_false(punycode.requires_published_dependencies)159  assert_false(bidi.requires_published_dependencies)160  assert_true(segmentation.requires_published_dependencies)161  assert_true(normalization.requires_published_dependencies)162  assert_true(casefold.requires_published_dependencies)163  inspect(casefold.directory, content="casefold")164  inspect(casefold.name, content="unicode-casefold")165  assert_true(idna.requires_published_dependencies)166  assert_true(unicode.requires_published_dependencies)167  inspect(unicode.directory, content="unicode")168  inspect(unicode.manifest_path(), content="unicode/moon.mod")169}170171///|172/// Every module that can be validated before this release publishes anything173/// must be: otherwise a rejected archive would surface only after the modules174/// before it had been published irreversibly.175///176test "preflight covers every module that does not depend on this release" {177  assert_eq(preflight_modules().map(release_module => release_module.name), [178    "unicode-data", "punycode", "unicode-bidi",179  ])180}181182///|183test "publish dry-run verdict does not depend on stream order" {184  // `run_publish_dry_run` captures stdout and stderr separately and185  // concatenates them, so the streams are not interleaved: text printed after186  // the reported failure must not flip the verdict.187  let output =188    #|Server status: 202 Accepted, detail: Dry run completed successfully. No changes were made. The dry-run was made for package moonbit-community/unicode-data version 0.4.0.189    #|Error: `moon publish` failed190    #|warning: trailing stderr text191  assert_true(192    publish_dry_run_succeeded(193      255, output, "moonbit-community/unicode-data", "0.4.0",194    ),195  )196}197