steid

@jamesgill /

1//! What the merge button does, and what this machine's git can do.
2
3use std::{
4 path::PathBuf,
5 process::Stdio,
6 sync::{Arc, Mutex},
7 time::SystemTime,
8};
9
10use crate::{
11 application::port::{CommitTreeRequest, GitMerge, GitMergeError},
12 domain::{ObjectId, OrgName, RefName, RepoName},
13};
14
15use super::{count_spawn, git_command};
16
17// --- Merging ------------------------------------------------------------------------
18
19/// The oldest git that can merge inside a bare repository.
20///
21/// `git merge-tree --write-tree` arrived in 2.38. Before that, `merge-tree` meant
22/// something else entirely — a three-way *diff* that wrote nothing — so an older git
23/// does not fail with a clear message, it succeeds at the wrong thing. That is why the
24/// version is read at boot and the merge box is absent rather than broken where it is
25/// too old: a check that only fired at merge time would be a check nobody sees until
26/// they have already written the pull request.
27const MERGE_TREE_SINCE: (u32, u32) = (2, 38);
28
29/// The oldest git that can pin an import to the addresses Steid checked.
30///
31/// `http.curloptResolve` arrived in git 2.37.0. Its release notes
32/// (`Documentation/RelNotes/2.37.0.txt`): "With the new http.curloptResolve
33/// configuration, the CURLOPT_RESOLVE mechanism that allows cURL based applications to
34/// use pre-resolved IP addresses for the requests is exposed to the scripts." Neither
35/// 2.36.0's `http.c` nor its `Documentation/config/http.txt` knows the key.
36///
37/// An older git does not fail on it — it ignores configuration it does not know — so the
38/// clone would resolve the name again and the pin would be silently absent, which is
39/// DNS rebinding left open. That is why an import is refused below this version rather
40/// than run without the pin.
41pub(super) const CURLOPT_RESOLVE_SINCE: (u32, u32) = (2, 37);
42
43/// What this machine's `git` can do, read once at boot.
44///
45/// One struct rather than a bare version number, because a version is a fact about git
46/// and this is a fact about what Steid may offer — and the pages only ever ask the
47/// second question. Adding a capability later is a field here, not a comparison
48/// scattered across use cases.
49#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
50pub struct GitFeatures {
51 /// Whether `git merge-tree --write-tree` is available, and therefore whether a pull
52 /// request can be merged from the web at all.
53 pub merge_tree: bool,
54
55 /// Whether `http.curloptResolve` is available, and therefore whether a repository
56 /// can be imported at all: an import is pinned to the addresses that were checked,
57 /// and a git that cannot pin is refused rather than trusted to resolve again.
58 pub pinned_resolve: bool,
59
60 /// The major and minor version git reported, when it could be read at all.
61 ///
62 /// Kept beside the capability rather than replacing it, because the two answer
63 /// different questions: a page asks what Steid may offer, and an operator asks what
64 /// is installed on the machine — a number a control plane compares across a fleet
65 /// and puts in a "your git is too old" alert. Two components only, because
66 /// [`parse_git_version`] reads two and a feature floor has never needed a third.
67 ///
68 /// `None` for a git that could not be run or whose output could not be parsed, which
69 /// is the same case that leaves every capability off.
70 pub version: Option<(u32, u32)>,
71}
72
73impl GitFeatures {
74 /// The version as `2.47`, for a response body. `None` where the version is.
75 #[must_use]
76 pub fn version_string(&self) -> Option<String> {
77 self.version
78 .map(|(major, minor)| format!("{major}.{minor}"))
79 }
80}
81
82impl GitFeatures {
83 /// Asks git what version it is and decides what that allows.
84 ///
85 /// **Never fails.** A git that cannot be run or whose output cannot be parsed
86 /// reports no capabilities, which degrades the merge box into its "this server
87 /// cannot merge" state rather than refusing to boot. Steid needs git for everything
88 /// else too, so a truly missing binary announces itself within one request anyway.
89 pub async fn detect() -> Self {
90 let mut command = git_command();
91 command.arg("--version").stdin(Stdio::null());
92 count_spawn(&command);
93
94 let Ok(output) = command.output().await else {
95 return Self::default();
96 };
97
98 Self::of_version(parse_git_version(&String::from_utf8_lossy(&output.stdout)))
99 }
100
101 /// What a git of this version can do. `None` — a version that could not be read —
102 /// can do nothing.
103 pub(super) fn of_version(version: Option<(u32, u32)>) -> Self {
104 Self {
105 merge_tree: version.is_some_and(|version| version >= MERGE_TREE_SINCE),
106 pinned_resolve: version.is_some_and(|version| version >= CURLOPT_RESOLVE_SINCE),
107 version,
108 }
109 }
110}
111
112/// Reads `git version 2.47.1` — and `git version 2.39.5 (Apple Git-154)` — as `(2, 47)`.
113///
114/// Only the first two components, because that is the whole of what a feature floor is
115/// ever expressed in. A patch release has never added a subcommand.
116fn parse_git_version(output: &str) -> Option<(u32, u32)> {
117 let version = output.split_whitespace().nth(2)?;
118 let mut parts = version.split('.');
119
120 Some((parts.next()?.parse().ok()?, parts.next()?.parse().ok()?))
121}
122
123/// Merges written into bare repositories under a data directory.
124///
125/// The write half of a merge, whose read half — "would this even merge?" — is
126/// [`GitQuery::merge_preview`]. They are separate ports for the reason
127/// [0006](../../plans/decisions/0006-git-binary-behind-narrow-ports.md) separates
128/// everything else: asking is safe and idempotent, and moving a branch is neither.
129#[derive(Debug, Clone)]
130pub struct DiskGitMerge {
131 data_dir: PathBuf,
132}
133
134impl DiskGitMerge {
135 pub fn new(data_dir: impl Into<PathBuf>) -> Self {
136 Self {
137 data_dir: data_dir.into(),
138 }
139 }
140
141 /// Where a repository lives, matching `DiskGitStorage`'s layout.
142 fn repo_path(&self, handle: &OrgName, name: &RepoName) -> PathBuf {
143 self.data_dir
144 .join(handle.as_str())
145 .join(format!("{name}.git"))
146 }
147
148 /// Moves or deletes a ref, guarded on where it is now.
149 ///
150 /// One function for both because they differ only by a `-d` and by whether a new
151 /// value is passed, and the interesting half — telling "somebody pushed" apart from
152 /// "git broke" — is identical and worth having in one place.
153 async fn guarded_update(
154 &self,
155 handle: &OrgName,
156 name: &RepoName,
157 branch: &RefName,
158 new: Option<&ObjectId>,
159 old: &ObjectId,
160 ) -> Result<(), GitMergeError> {
161 let path = self.repo_path(handle, name);
162 let full = format!("refs/heads/{branch}");
163
164 let mut command = git_command();
165 command
166 .arg("--git-dir")
167 .arg(&path)
168 .arg("update-ref")
169 .stdin(Stdio::null());
170
171 count_spawn(&command);
172
173 match new {
174 Some(new) => {
175 command.arg(&full).arg(new.as_str()).arg(old.as_str());
176 }
177 None => {
178 command.arg("-d").arg(&full).arg(old.as_str());
179 }
180 }
181
182 let output = command
183 .output()
184 .await
185 .map_err(|error| GitMergeError::backend(format!("could not run git: {error}")))?;
186
187 if output.status.success() {
188 return Ok(());
189 }
190
191 let stderr = String::from_utf8_lossy(&output.stderr);
192
193 // git has no distinct exit status for "the old value did not match" — it is 1,
194 // and so is everything else — so the sentence is what tells them apart. It is
195 // matched loosely on purpose: the two spellings git has used are "is at … but
196 // expected …" for a move and "is at … but expected …" for a delete, and a
197 // future third would still contain "expected".
198 if stderr.contains("but expected") {
199 return Err(GitMergeError::Stale);
200 }
201
202 Err(GitMergeError::backend(format!(
203 "git update-ref exited with {}: {}",
204 output.status,
205 stderr.trim()
206 )))
207 }
208}
209
210impl GitMerge for DiskGitMerge {
211 async fn commit_tree(
212 &self,
213 handle: &OrgName,
214 name: &RepoName,
215 request: &CommitTreeRequest,
216 ) -> Result<ObjectId, GitMergeError> {
217 let path = self.repo_path(handle, name);
218
219 let mut command = git_command();
220 command
221 .arg("--git-dir")
222 .arg(&path)
223 .arg("commit-tree")
224 .arg(request.tree.as_str());
225
226 for parent in &request.parents {
227 command.arg("-p").arg(parent.as_str());
228 }
229
230 // `-m` rather than the message on stdin: a commit message is bounded by the
231 // pull request's own body cap, and passing it as an argument keeps this one
232 // process with no plumbing to get wrong.
233 command.arg("-m").arg(&request.message);
234
235 let stamp = git_timestamp(request.now);
236
237 // Author *and* committer, both the person who pressed Merge. Nobody else is
238 // more the author of a merge commit than whoever decided to make it, and a
239 // commit whose author git had to invent from the host's hostname is a commit
240 // nobody can attribute later.
241 //
242 // The date is passed rather than left to git's own clock so that a use case
243 // taking a `now` actually controls the commit it makes — the same rule every
244 // other timestamp in Steid follows.
245 command
246 .env("GIT_AUTHOR_NAME", &request.author_name)
247 .env("GIT_AUTHOR_EMAIL", &request.author_email)
248 .env("GIT_AUTHOR_DATE", &stamp)
249 .env("GIT_COMMITTER_NAME", &request.author_name)
250 .env("GIT_COMMITTER_EMAIL", &request.author_email)
251 .env("GIT_COMMITTER_DATE", &stamp)
252 .stdin(Stdio::null());
253 count_spawn(&command);
254
255 let output = command
256 .output()
257 .await
258 .map_err(|error| GitMergeError::backend(format!("could not run git: {error}")))?;
259
260 if !output.status.success() {
261 return Err(GitMergeError::backend(format!(
262 "git commit-tree exited with {}: {}",
263 output.status,
264 String::from_utf8_lossy(&output.stderr).trim()
265 )));
266 }
267
268 let id = String::from_utf8_lossy(&output.stdout);
269
270 ObjectId::new(id.trim())
271 .map_err(|error| GitMergeError::backend(format!("git named a bad commit: {error}")))
272 }
273
274 async fn update_ref(
275 &self,
276 handle: &OrgName,
277 name: &RepoName,
278 branch: &RefName,
279 new: &ObjectId,
280 old: &ObjectId,
281 ) -> Result<(), GitMergeError> {
282 self.guarded_update(handle, name, branch, Some(new), old)
283 .await
284 }
285
286 async fn delete_ref(
287 &self,
288 handle: &OrgName,
289 name: &RepoName,
290 branch: &RefName,
291 old: &ObjectId,
292 ) -> Result<(), GitMergeError> {
293 self.guarded_update(handle, name, branch, None, old).await
294 }
295}
296
297/// A time in the one date format git will not try to be clever about.
298///
299/// `@<seconds> <zone>` is git's raw form, and the `@` is load-bearing: without it git
300/// runs the value through its human-date parser, which reads a bare `1700000000` as an
301/// epoch by luck and refuses `0` outright — so a commit made at the epoch failed while
302/// every other one worked.
303///
304/// `+0000` always. Steid stores every time as an instant and has nowhere to get a
305/// person's zone from, and a made-up offset would be a claim about where somebody was.
306fn git_timestamp(now: SystemTime) -> String {
307 let seconds = now
308 .duration_since(SystemTime::UNIX_EPOCH)
309 .map(|elapsed| elapsed.as_secs())
310 .unwrap_or(0);
311
312 format!("@{seconds} +0000")
313}
314
315/// Merges recorded in memory, for testing use cases without a repository.
316///
317/// Records what it was asked to do and answers with ids a test seeded, so a use case
318/// test can assert the *sequence* — commit, then move the target, then delete the
319/// source — which is the part that has to be right and the part a disk fixture makes
320/// slow to check.
321#[derive(Debug, Default, Clone)]
322pub struct InMemoryGitMerge {
323 commits: Arc<Mutex<Vec<CommitTreeRequest>>>,
324 updates: Arc<Mutex<Vec<RecordedRefUpdate>>>,
325 /// The id every `commit_tree` answers with.
326 written: Option<ObjectId>,
327 /// Makes every ref update report that somebody else pushed first.
328 stale: bool,
329}
330
331/// One ref update a fake merge was asked to make. `new` is `None` for a delete.
332#[derive(Debug, Clone, PartialEq, Eq)]
333pub struct RecordedRefUpdate {
334 pub branch: RefName,
335 pub new: Option<ObjectId>,
336 pub old: ObjectId,
337}
338
339impl InMemoryGitMerge {
340 pub fn new() -> Self {
341 Self::default()
342 }
343
344 /// What `commit_tree` will answer with.
345 pub fn writing(id: &str) -> Self {
346 Self {
347 written: Some(ObjectId::from_trusted(format!("{id:0>40}"))),
348 ..Self::default()
349 }
350 }
351
352 /// A repository where every ref moved under the merge's feet.
353 pub fn stale() -> Self {
354 Self {
355 stale: true,
356 ..Self::default()
357 }
358 }
359
360 /// The commits it was asked to write, in order.
361 pub fn commits(&self) -> Vec<CommitTreeRequest> {
362 self.commits.lock().expect("lock poisoned").clone()
363 }
364
365 /// The ref updates it was asked to make, in order.
366 pub fn updates(&self) -> Vec<RecordedRefUpdate> {
367 self.updates.lock().expect("lock poisoned").clone()
368 }
369}
370
371impl GitMerge for InMemoryGitMerge {
372 async fn commit_tree(
373 &self,
374 _handle: &OrgName,
375 _name: &RepoName,
376 request: &CommitTreeRequest,
377 ) -> Result<ObjectId, GitMergeError> {
378 self.commits
379 .lock()
380 .expect("lock poisoned")
381 .push(request.clone());
382
383 Ok(self
384 .written
385 .clone()
386 .unwrap_or_else(|| ObjectId::from_trusted("c".repeat(40))))
387 }
388
389 async fn update_ref(
390 &self,
391 _handle: &OrgName,
392 _name: &RepoName,
393 branch: &RefName,
394 new: &ObjectId,
395 old: &ObjectId,
396 ) -> Result<(), GitMergeError> {
397 if self.stale {
398 return Err(GitMergeError::Stale);
399 }
400
401 self.updates
402 .lock()
403 .expect("lock poisoned")
404 .push(RecordedRefUpdate {
405 branch: branch.clone(),
406 new: Some(new.clone()),
407 old: old.clone(),
408 });
409
410 Ok(())
411 }
412
413 async fn delete_ref(
414 &self,
415 _handle: &OrgName,
416 _name: &RepoName,
417 branch: &RefName,
418 old: &ObjectId,
419 ) -> Result<(), GitMergeError> {
420 if self.stale {
421 return Err(GitMergeError::Stale);
422 }
423
424 self.updates
425 .lock()
426 .expect("lock poisoned")
427 .push(RecordedRefUpdate {
428 branch: branch.clone(),
429 new: None,
430 old: old.clone(),
431 });
432
433 Ok(())
434 }
435}
436
437#[cfg(test)]
438mod tests {
439 use std::path::Path;
440
441 use tempfile::TempDir;
442
443 use super::*;
444 use crate::infrastructure::git::fixture::{git_says, handle, repo_name};
445
446 // --- Merging ----------------------------------------------------------------------
447
448 /// A bare repository with `main` and a `tidy` branch off it, and the merge adapter
449 /// pointed at the same data directory.
450 ///
451 /// Returns the repository path too, because every assertion here is "what does git
452 /// believe now" rather than "what did the adapter say".
453 fn mergeable() -> (TempDir, DiskGitMerge, PathBuf) {
454 let dir = TempDir::new().expect("temp dir");
455 let repo = dir.path().join("jamesgill").join("steid.git");
456 let work = dir.path().join("work");
457
458 let git = |path: &Path, args: &[&str]| -> String {
459 let output = std::process::Command::new("git")
460 .arg("-C")
461 .arg(path)
462 .args(args)
463 .env("GIT_CONFIG_GLOBAL", "/dev/null")
464 .env("GIT_CONFIG_SYSTEM", "/dev/null")
465 .env("GIT_AUTHOR_NAME", "Ada Lovelace")
466 .env("GIT_AUTHOR_EMAIL", "ada@example.com")
467 .env("GIT_COMMITTER_NAME", "Ada Lovelace")
468 .env("GIT_COMMITTER_EMAIL", "ada@example.com")
469 .output()
470 .expect("git should be on PATH");
471
472 assert!(
473 output.status.success(),
474 "git {args:?} failed: {}",
475 String::from_utf8_lossy(&output.stderr)
476 );
477
478 String::from_utf8_lossy(&output.stdout).trim().to_owned()
479 };
480
481 std::fs::create_dir_all(&work).expect("create work tree");
482 git(
483 dir.path(),
484 &[
485 "init",
486 "--bare",
487 "--quiet",
488 "--template=",
489 "--initial-branch=main",
490 "--",
491 repo.to_str().expect("utf-8 fixture path"),
492 ],
493 );
494
495 git(&work, &["init", "--quiet", "-b", "main"]);
496 std::fs::write(work.join("README.md"), b"hello\n").expect("write");
497 git(&work, &["add", "-A"]);
498 git(&work, &["commit", "--quiet", "-m", "first"]);
499
500 git(&work, &["checkout", "--quiet", "-b", "tidy"]);
501 std::fs::write(work.join("other.txt"), b"tidy\n").expect("write");
502 git(&work, &["add", "-A"]);
503 git(&work, &["commit", "--quiet", "-m", "tidy"]);
504
505 git(
506 &work,
507 &[
508 "push",
509 "--quiet",
510 repo.to_str().expect("utf-8"),
511 "main",
512 "tidy",
513 ],
514 );
515
516 let merges = DiskGitMerge::new(dir.path());
517
518 (dir, merges, repo)
519 }
520
521 /// What a revision resolves to in the fixture.
522 fn head(repo: &Path, revision: &str) -> ObjectId {
523 ObjectId::new(git_says(repo, &["rev-parse", revision])).expect("a real object id")
524 }
525
526 #[tokio::test]
527 async fn a_merge_commit_carries_both_parents_and_the_person_who_pressed_merge() {
528 let (_dir, merges, repo) = mergeable();
529 let main = head(&repo, "main");
530 let tidy = head(&repo, "tidy");
531 let tree = ObjectId::new(git_says(&repo, &["rev-parse", "tidy^{tree}"])).expect("a tree");
532
533 let commit = merges
534 .commit_tree(
535 &handle(),
536 &repo_name("steid"),
537 &CommitTreeRequest {
538 tree,
539 parents: vec![main.clone(), tidy.clone()],
540 message: "Merge pull request #7 from tidy\n\nTidy things up.".to_owned(),
541 author_name: "Ada Lovelace".to_owned(),
542 author_email: "ada@example.com".to_owned(),
543 now: SystemTime::UNIX_EPOCH + std::time::Duration::from_secs(1_700_000_000),
544 },
545 )
546 .await
547 .expect("should write a commit");
548
549 // The target first, so the first-parent line stays the target's history.
550 assert_eq!(
551 git_says(
552 &repo,
553 &["rev-list", "--parents", "-n", "1", commit.as_str()]
554 ),
555 format!("{commit} {main} {tidy}")
556 );
557 assert_eq!(
558 git_says(
559 &repo,
560 &["log", "-1", "--format=%an <%ae> %at", commit.as_str()]
561 ),
562 "Ada Lovelace <ada@example.com> 1700000000",
563 "the caller's `now` decides the commit's date, not git's clock"
564 );
565 // Written, and *not* referenced: the ref update is a separate, later step.
566 assert_eq!(git_says(&repo, &["rev-parse", "main"]), main.as_str());
567 }
568
569 #[tokio::test]
570 async fn a_squash_commit_has_one_parent() {
571 let (_dir, merges, repo) = mergeable();
572 let main = head(&repo, "main");
573 let tree = ObjectId::new(git_says(&repo, &["rev-parse", "tidy^{tree}"])).expect("a tree");
574
575 let commit = merges
576 .commit_tree(
577 &handle(),
578 &repo_name("steid"),
579 &CommitTreeRequest {
580 tree,
581 parents: vec![main.clone()],
582 message: "Tidy things up (#7)".to_owned(),
583 author_name: "Ada Lovelace".to_owned(),
584 author_email: "ada@example.com".to_owned(),
585 now: SystemTime::UNIX_EPOCH,
586 },
587 )
588 .await
589 .expect("should write a commit");
590
591 assert_eq!(
592 git_says(
593 &repo,
594 &["rev-list", "--parents", "-n", "1", commit.as_str()]
595 ),
596 format!("{commit} {main}")
597 );
598 }
599
600 #[tokio::test]
601 async fn moving_a_branch_from_where_it_is_moves_it() {
602 let (_dir, merges, repo) = mergeable();
603 let main = head(&repo, "main");
604 let tidy = head(&repo, "tidy");
605
606 merges
607 .update_ref(
608 &handle(),
609 &repo_name("steid"),
610 &RefName::from_trusted("main"),
611 &tidy,
612 &main,
613 )
614 .await
615 .expect("should move the branch");
616
617 assert_eq!(git_says(&repo, &["rev-parse", "main"]), tidy.as_str());
618 }
619
620 #[tokio::test]
621 async fn moving_a_branch_from_where_it_is_not_changes_nothing() {
622 // The compare-and-swap that makes a concurrent push lose cleanly rather than
623 // being silently discarded.
624 let (_dir, merges, repo) = mergeable();
625 let main = head(&repo, "main");
626 let tidy = head(&repo, "tidy");
627
628 let error = merges
629 .update_ref(
630 &handle(),
631 &repo_name("steid"),
632 &RefName::from_trusted("main"),
633 &main,
634 &tidy,
635 )
636 .await
637 .expect_err("expected the guard to refuse");
638
639 assert!(error.is_stale(), "expected staleness, got {error:?}");
640 assert_eq!(git_says(&repo, &["rev-parse", "main"]), main.as_str());
641 }
642
643 #[tokio::test]
644 async fn deleting_a_branch_is_guarded_the_same_way() {
645 let (_dir, merges, repo) = mergeable();
646 let main = head(&repo, "main");
647 let tidy = head(&repo, "tidy");
648
649 let refused = merges
650 .delete_ref(
651 &handle(),
652 &repo_name("steid"),
653 &RefName::from_trusted("tidy"),
654 &main,
655 )
656 .await
657 .expect_err("expected the guard to refuse");
658 assert!(refused.is_stale(), "expected staleness, got {refused:?}");
659
660 merges
661 .delete_ref(
662 &handle(),
663 &repo_name("steid"),
664 &RefName::from_trusted("tidy"),
665 &tidy,
666 )
667 .await
668 .expect("should delete the branch");
669
670 assert_eq!(
671 git_says(
672 &repo,
673 &["for-each-ref", "--format=%(refname)", "refs/heads/"]
674 ),
675 "refs/heads/main"
676 );
677 }
678
679 // --- What this git can do ----------------------------------------------------------
680
681 #[test]
682 fn a_version_reads_as_major_and_minor() {
683 assert_eq!(parse_git_version("git version 2.47.1\n"), Some((2, 47)));
684 // Apple's git appends a build, which must not stop the parse.
685 assert_eq!(
686 parse_git_version("git version 2.39.5 (Apple Git-154)\n"),
687 Some((2, 39))
688 );
689 assert_eq!(parse_git_version(""), None);
690 assert_eq!(parse_git_version("git version banana"), None);
691 }
692
693 #[tokio::test]
694 async fn this_machine_reports_what_its_git_can_do() {
695 // Not an assertion about the answer — a developer may be on an old git — but
696 // about detection producing one rather than panicking or hanging.
697 let features = GitFeatures::detect().await;
698
699 assert_eq!(
700 features,
701 GitFeatures::of_version(parse_git_version(&git_says(Path::new("."), &["--version"])))
702 );
703 }
704
705 #[test]
706 fn each_capability_starts_at_its_own_version() {
707 let at = |major, minor| GitFeatures::of_version(Some((major, minor)));
708
709 // 2.34 is Ubuntu 22.04's: neither.
710 assert!(!at(2, 34).pinned_resolve);
711 assert!(!at(2, 36).pinned_resolve);
712 assert!(at(2, 37).pinned_resolve);
713 assert!(!at(2, 37).merge_tree);
714 assert!(at(2, 38).merge_tree);
715 assert!(at(3, 0).pinned_resolve && at(3, 0).merge_tree);
716
717 assert_eq!(GitFeatures::of_version(None), GitFeatures::default());
718 }
719
720 #[tokio::test]
721 async fn detection_reports_the_version_it_decided_on() {
722 let features = GitFeatures::detect().await;
723 let parsed = parse_git_version(&git_says(Path::new("."), &["--version"]));
724
725 assert_eq!(features.version, parsed);
726 assert_eq!(
727 features.version_string(),
728 parsed.map(|(major, minor)| format!("{major}.{minor}")),
729 );
730 }
731}