Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/al-test-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ fn run_version_inner(
match &deps.build {
Some(u) => {
println!("bc build: {} ({})", u.build, origin_word(u.origin));
chosen.target.bc.build = Some(u.build.to_string());
chosen.target.bc.resolved_to(&u.build.to_string());
bc_build = Some(u.build.to_string());
let fetch = al_deps::artifact::Fetch {
cache_root: al_deps::cache::cache_root_from_env(args.cache_dir.as_deref()),
Expand Down
37 changes: 37 additions & 0 deletions crates/al-version/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ impl BcVersion {
})
}

/// The run's version once the Microsoft apps were found: `build` is that build (`29.1.57326.58275`). The minor follows
/// it, so a major-only `--bc-version 29` on a 29.1 build is the target `29.1` names (al-runner issue 8209). A build of
/// another major leaves the minor as it was.
pub fn resolved_to(&mut self, build: &str) {
if let Ok(b) = BcVersion::parse(build)
&& b.major == self.major
{
self.minor = b.minor;
}
self.build = Some(build.to_string());
}

/// True when `prefix` (`27`, `27.5`) is a whole-segment prefix of this
/// version: `27.5` matches `27.5.46862.1` but not `27.50`.
pub fn matches_prefix(&self, prefix: &str) -> bool {
Expand Down Expand Up @@ -263,6 +275,31 @@ mod tests {
BcVersion::parse(s).unwrap()
}

// al-runner issue 8209: `--bc-version 29`, `29.1` and the full build pick the same 29.1 build, so the target is that
// build however it was named, and the Feature Key rows measured on 29.0 only are refused on it in all three.
#[test]
fn the_target_follows_the_build_the_microsoft_apps_come_from() {
let build = "29.1.57326.58275";
for asked in ["29", "29.1", build] {
let mut t = Target::for_bc(bc(asked));
t.bc.resolved_to(build);
assert_eq!(
(t.bc.major, t.bc.minor, t.bc.to_string()),
(29, 1, build.to_string()),
"{asked}"
);
assert_eq!(feature_key_rows(Some(&t)), None, "{asked}");
}
// Neighbor: a 29.0 build keeps main's 29.0 rows.
let mut t = Target::for_bc(bc("29"));
t.bc.resolved_to("29.0.54011.56262");
assert_eq!(feature_key_rows(Some(&t)), Some(FeatureKeyRows::Bc29));
// A build of another major leaves the minor as main did; the build string is still recorded.
let mut t = Target::for_bc(bc("29"));
t.bc.resolved_to("28.5.54151.58194");
assert_eq!((t.bc.major, t.bc.minor), (29, 0));
}

#[test]
fn runtime_is_bc_major_minus_eleven() {
assert_eq!(Runtime::for_bc(27), Runtime { major: 16, minor: 0 });
Expand Down
8 changes: 3 additions & 5 deletions crates/alrunner-cli/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1375,18 +1375,16 @@ fn test_inner(
}
let mut bc_build = None;
if let Some(u) = &dependencies.build {
chosen.target.bc.build = Some(u.build.to_string());
// The target is the build the Microsoft apps come from (`BcVersion::resolved_to`).
chosen.target.bc.resolved_to(&u.build.to_string());
bc_build = Some(u.build.to_string());
if from_packages && Some(&u.build) != preferred_build.as_ref() {
// The build the packages come from is neither cached nor published: the usual rules chose
// another one of the same major, and the target follows what the apps really are.
// another one of the same major.
build_rule.push_str(&format!(
"; that build is not cached, on disk or published, so BC {} was used",
u.build
));
if u.build.major() == u32::from(chosen.target.bc.major) {
chosen.target.bc.minor = u.build.minor() as u16;
}
}
}
// ADR-060 decision 2: `--license FILE`, else the license of the BC artifacts of the build, else none. A file that
Expand Down
2 changes: 1 addition & 1 deletion docs/codemap.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ al-testkit dev only: compile AL from a string and run a routine al-testf
- `awaited.rs`: Behavior that differs between BC versions in an open corpus probe, before a bump pins its guard (not a `Gate`; `tests/gate_completeness.rs` fails at the bump until it becomes one). Entry: `journal_temp_part_reads_after_refresh`.
- `choose.rs` (238): How the target of a run is chosen (ADR-015 3.2, 3.8). Entry: `AppVersions` 10, `TargetError` 58, `Chosen` 84, `choose_target` 98.
- `gates.rs` (115): Behaviour that differs between BC versions, as named facts in one table (ADR-015 3.4). Entry: `Evidence` 12, `Gate` 18, `has` 69.
- `lib.rs` (291): BC versions and the run target (ADR-015). Entry: `VersionError` 21, `BcVersion` 42, `Runtime` 50, `Target` 56.
- `lib.rs` (~330): BC versions and the run target (ADR-015). `BcVersion::resolved_to` makes the target the build the Microsoft apps came from (minor and build string; both CLIs call it, al-runner issue 8209). Entry: `VersionError` 21, `BcVersion` 42, `Runtime` 50, `Target` 56.

### al-vm

Expand Down
Loading