Skip to content

Commit adbc32f

Browse files
authored
Relax semver-checks to compare worlds in packages with different versions (bytecodealliance#1886)
In wasm-tools component semver-checks, instead of requiring that the old and new world live in packages with the same id, just require that they have the same name. This allows checking for semver compatibility between different versions of a package, for example, this command: ```shell $ wasm-tools component semver-check --prev wasi:http/[email protected] --new wasi:http/[email protected] ./wit ``` in a dirctory with `wit/deps/[email protected]` contains the current wasi-http wit files, and `wit/deps/[email protected]` contains a new set of wit files, checks that the new version is semver-compatible.
1 parent c9218cf commit adbc32f

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

crates/wit-component/src/semver_check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub fn semver_check(mut resolve: Resolve, prev: WorldId, new: WorldId) -> Result
5555
.package
5656
.context("new world not in named package")?;
5757
let new_pkg_name = &resolve.packages[new_pkg_id].name;
58-
if old_pkg_id != new_pkg_id {
58+
if old_pkg_name != new_pkg_name {
5959
bail!("the old world is in package {old_pkg_name}, which is not the same as the new world, which is in package {new_pkg_name}", )
6060
}
6161

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// FAIL: component semver-check % --prev a:b/[email protected] --new a:b/[email protected]
2+
3+
package foo:root;
4+
package a:b@0.2.0 {
5+
world worldly {
6+
import a: func();
7+
import b: interface {}
8+
}
9+
}
10+
11+
package a:b@0.2.1 {
12+
world worldly {
13+
}
14+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
error: new world is not semver-compatible with the previous world
2+
3+
Caused by:
4+
0: type mismatch for import `worldly`
5+
missing import named `a` (at offset 0x186)

0 commit comments

Comments
 (0)