Skip to content

Commit 2400158

Browse files
committed
Flip :/ baseline skip from CI to local and extend
For #1622, baseline comparisons in `find_youngest_matching_commit` where Git 2.47.* produces incorrect results were conditionally suppressed in the `regex_matches` test case in #1635. That was refined in #1719, and further refined in #1774. This builds on those, making substantial changes, in view of how: - We expect that CI have a very recent Git. The runners have been past 2.47.* for some time, and now have 2.49.*. Therefore it is no longer desirable to suppress the baseline comparison on CI. - #1774 only examined the `regex_matches` test case. That test runs when the `revparse-regex` feature, which is a default `gix` feature, is enabled. But when `revparse-regex` is not enabled, the `contained_string_matches` test case runs instead. This test suffers the same baseline comparison failures with the same Git versions, due to assertions analogous to those that were adjusted to let `regex_matches` proceed and pass. This can be verified by running PATH="$HOME/git-2.47.2/bin:$PATH" GIX_TEST_IGNORE_ARCHIVES=1 \ cargo nextest run -p gix \ revision::spec::from_bytes::regex::find_youngest_matching_commit \ --no-fail-fast --no-default-features \ --features max-performance-safe,comfort,basic where the `PATH` environment variable is set differently if the `git` command provided in a Git 2.47.* installation is elsewhere than `~/git-2.47.2/bin`. Output from such a run can be seen in: https://gist.github.com/EliahKagan/bd8525d048350fc80a7666d8819089db Therefore, if a conditional suppression of the baseline comparison is to be preserved in `regex_matches`, then an analogous suppression under the same conditions should be added to `contained_string_matches`. - Although most operating systems that package Git seem not to have 2.47.* as their latest available downstream version in any release, it seems a few do. In particular, Alpine Linux v3.21 has git 2.47.2-r0, as shown at: https://pkgs.alpinelinux.org/packages?name=git&branch=v3.21&repo=&arch=x86_64&origin=&flagged=&maintainer= Therefore, if it is desirable to work with as wide a range as possible of (currently supported) operating system releases as development environments, there may be a benefit to conditionally suppressing the baseline tests when Git 2.47.* is used *locally*. - However, doing this locally carries two downsides. First, the test code (even if refactored to decrease duplication) will be more complicated than if this is not done. Second, such an environment will still not be suitable for all development tasks, because generating the relevant test fixtures on it will contain incorrect baselines and therefore must not be committed. If they were to be committed by accident, then the problem would most likely be caught, because the tests would fail on CI, in other environments, and even in the same environment when run without `GIX_TEST_IGNORE_ARCHIVES` (in the absence of which the baseline comparisons are not suppressed). So this is not likely to have severely harmful effects. But it could be frustrating, because suppressing the baseline comparisons locally hides the usual evidence that the generated archives might not be suitable for committing. This commit keeps the baseline comparison in `regex_matches` but inverts its CI check so the suppression is only done locally rather than only on CI, adds the same (modified) suppression to the analogous `contained_string_matches` test case, and updates comments accordingly. We may or may not keep this approach.
1 parent 6acdc04 commit 2400158

File tree

1 file changed

+37
-13
lines changed
  • gix/tests/gix/revision/spec/from_bytes

1 file changed

+37
-13
lines changed

gix/tests/gix/revision/spec/from_bytes/regex.rs

+37-13
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,40 @@ mod find_youngest_matching_commit {
6767
fn contained_string_matches() {
6868
let repo = repo("complex_graph").unwrap();
6969

70-
assert_eq!(
71-
parse_spec(":/message", &repo).unwrap(),
72-
Spec::from_id(hex_to_id("ef80b4b77b167f326351c93284dc0eb00dd54ff4").attach(&repo))
73-
);
70+
// See the comment on `skip_some_baselines` in the `regex_matches` test function below.
71+
let skip_some_baselines = !is_ci::cached()
72+
&& std::env::var_os("GIX_TEST_IGNORE_ARCHIVES").is_some()
73+
&& ((2, 47, 0)..(2, 48, 0)).contains(&gix_testtools::GIT_VERSION);
74+
75+
if skip_some_baselines {
76+
assert_eq!(
77+
parse_spec_no_baseline(":/message", &repo).unwrap(),
78+
Spec::from_id(hex_to_id("ef80b4b77b167f326351c93284dc0eb00dd54ff4").attach(&repo))
79+
);
80+
} else {
81+
assert_eq!(
82+
parse_spec(":/message", &repo).unwrap(),
83+
Spec::from_id(hex_to_id("ef80b4b77b167f326351c93284dc0eb00dd54ff4").attach(&repo))
84+
);
85+
}
7486

7587
assert_eq!(
7688
parse_spec("@^{/!-B}", &repo).unwrap(),
7789
Spec::from_id(hex_to_id("55e825ebe8fd2ff78cad3826afb696b96b576a7e").attach(&repo)),
7890
"negations work as well"
7991
);
8092

81-
assert_eq!(
82-
parse_spec(":/!-message", &repo).unwrap(),
83-
Spec::from_id(hex_to_id("55e825ebe8fd2ff78cad3826afb696b96b576a7e").attach(&repo))
84-
);
93+
if skip_some_baselines {
94+
assert_eq!(
95+
parse_spec_no_baseline(":/!-message", &repo).unwrap(),
96+
Spec::from_id(hex_to_id("55e825ebe8fd2ff78cad3826afb696b96b576a7e").attach(&repo))
97+
);
98+
} else {
99+
assert_eq!(
100+
parse_spec(":/!-message", &repo).unwrap(),
101+
Spec::from_id(hex_to_id("55e825ebe8fd2ff78cad3826afb696b96b576a7e").attach(&repo))
102+
);
103+
}
85104

86105
assert_eq!(
87106
parse_spec_no_baseline(":/messa.e", &repo).unwrap_err().to_string(),
@@ -95,16 +114,21 @@ mod find_youngest_matching_commit {
95114
fn regex_matches() {
96115
let repo = repo("complex_graph").unwrap();
97116

98-
// The full Linux CI `test` job regenerates baselines instead of taking them from archives.
99-
// Traversal order with `:/` is broken in Git 2.47.*, so some `parse_spec` assertions fail.
100-
// The fix is in Git 2.48.* but is not backported. For now, we use `parse_spec_no_baseline`
101-
// in affected test cases when they are run on CI with Git 2.47.*. For details, see:
117+
// Traversal order with `:/` was broken in Git 2.47.*, so some `parse_spec` assertions
118+
// fail. The fix is in Git 2.48.* but is not backported. This causes incorrect baselines to
119+
// be computed when `GIX_TEST_IGNORE_ARCHIVES` is set. If that is not set, then archived
120+
// baselines are used and there is no problem. On CI, we assume a sufficiently new version
121+
// of Git. Otherwise, if `GIX_TEST_IGNORE_ARCHIVES` is set and Git 2.47.* is used, we skip
122+
// the baseline check, to allow the rest of the test to proceed. This accommodates local
123+
// development environments with a system-provided Git 2.47.*, though archives generated on
124+
// such a system should not be committed, as they would still contain incorrect baselines.
125+
// Please note that this workaround may be removed in the future. For more details, see:
102126
//
103127
// - https://lore.kernel.org/git/[email protected]/T/
104128
// - https://lore.kernel.org/git/[email protected]/T/
105129
// - https://github.com/git/git/blob/v2.48.0/Documentation/RelNotes/2.48.0.txt#L294-L296
106130
// - https://github.com/GitoxideLabs/gitoxide/issues/1622
107-
let skip_some_baselines = is_ci::cached()
131+
let skip_some_baselines = !is_ci::cached()
108132
&& std::env::var_os("GIX_TEST_IGNORE_ARCHIVES").is_some()
109133
&& ((2, 47, 0)..(2, 48, 0)).contains(&gix_testtools::GIT_VERSION);
110134

0 commit comments

Comments
 (0)