moonrockzmoonspec
v0.11.0next
You are reading the docs for main (unreleased). Go to the v0.11.0 docs.
Docs / Migrating to moonspec 0.12.0
On this page1. Use MoonBit 0.10.20 or newer2. Import the async facade3. Registry build rules select the execution4. Source API changes5. cucumber-messages 0.6.0

Migrating to moonspec 0.12.0

This guide tells you how to update a project from moonspec 0.11.0 to 0.12.0. All projects need step 1. Steps 2 to 5 apply only if your project uses what they name.

If you...Read
use moonspec 0.12.0 at all1. Use MoonBit 0.10.20 or newer
run moonspec tests with async test2. Import the async facade
generate build rules with gen build --moonx3. Registry build rules select the execution
build MoonspecConfig or CodegenConfig values in code4. Source API changes
build cucumber-messages pickle values in code5. cucumber-messages 0.6.0

1. Use MoonBit 0.10.20 or newer

moonspec 0.12.0 needs MoonBit 0.10.20 or newer (moonc v0.10.20+65efd5b93, moon 0.1.20261104). It depends on cucumber-messages 0.6.0, which uses the #derive(...) attribute syntax and the moonbitlang/core/json package API. Older toolchains do not accept them. On an older toolchain, stay on moonspec 0.11.0.

MoonBit 0.10.20 deprecates the trailing derive(...) syntax. Write the World's derive as an attribute before the struct. moon fmt on 0.10.20 does this for you:

#derive(Default)
struct CalcWorld {
  mut result : Int
}

2. Import the async facade

The root package and runner no longer export the async run and run_or_fail. Change the package import of async test packages to the async facade:

import {
  "moonrockz/moonspec/async" @moonspec,
}

The calls, World and Setup definitions do not change. The root package now has sync run_sync and run_or_fail_sync, which also run on Wasm-GC. See Async migration and Sync execution and target support.

3. Registry build rules select the execution

moonspec gen build --moonx pins the CLI version that runs it. With 0.12.0 the rule calls moonx moonrockz/moonspec/cmd/moonspec@0.12.0 and includes --execution async or --execution sync. Sync now works with --moonx.

Rules made with 0.11.0 pin @0.11.0, which does not build on MoonBit 0.10.20. Run moonspec gen build ... --moonx --apply again to update the rule's CLI pin and execution flag. Other rules in moon.pkg stay as they are.

4. Source API changes

MoonspecConfig.execution is now ExecutionPolicy? and CodegenConfig.execution is ExecutionPolicy. Both structs also have a shared : SharedConfig? field. generate_test_file raises GenerationError::SharedGenerationRequired for shared or target-policy configuration. See Source API migration.

5. cucumber-messages 0.6.0

moonspec now uses cucumber-messages 0.6.0 instead of 0.3.0. If your code builds PickleDocString or PickleTable records, add the optional argumentIndex field. None keeps the earlier output:

let doc : @cucumber_messages.PickleDocString = {
  argumentIndex: None,
  content: "text",
  mediaType: None,
}

The cucumber-messages changelog lists its other changes.

Edit this page on GitHub ↗