Skip to content

Commit aeaebec

Browse files
authored
Merge pull request #1687 from EliahKagan/run-ci/32bit
Fix 32-bit test failures and test workspace on a 32-bit target on CI
2 parents 9ab86a2 + dc0a73a commit aeaebec

File tree

24 files changed

+234
-117
lines changed

24 files changed

+234
-117
lines changed

.github/workflows/ci.yml

+43-4
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,42 @@ jobs:
198198
test-32bit:
199199
runs-on: ubuntu-latest
200200

201+
container: i386/debian:stable-slim
202+
203+
steps:
204+
- name: Prerequisites
205+
run: |
206+
prerequisites=(
207+
build-essential
208+
ca-certificates
209+
cmake
210+
curl
211+
git
212+
jq
213+
libssl-dev
214+
libstdc++6:amd64 # To support external 64-bit Node.js for actions.
215+
pkgconf
216+
)
217+
dpkg --add-architecture amd64
218+
apt-get update
219+
apt-get install --no-install-recommends -y -- "${prerequisites[@]}"
220+
shell: bash
221+
- uses: actions/checkout@v4
222+
- uses: dtolnay/rust-toolchain@stable
223+
with:
224+
toolchain: stable-i686-unknown-linux-gnu # Otherwise it may misdetect based on the amd64 kernel.
225+
- uses: Swatinem/rust-cache@v2
226+
- uses: taiki-e/install-action@v2
227+
with:
228+
tool: nextest
229+
- name: Make `system` scope nonempty for "GitInstallation" tests
230+
run: git config --system gitoxide.imaginary.arbitraryVariable arbitraryValue
231+
- name: Test (nextest)
232+
run: cargo nextest run --workspace --no-fail-fast
233+
234+
test-32bit-cross:
235+
runs-on: ubuntu-latest
236+
201237
strategy:
202238
matrix:
203239
target: [ armv7-linux-androideabi ]
@@ -211,15 +247,17 @@ jobs:
211247
with:
212248
toolchain: stable
213249
targets: ${{ matrix.target }}
214-
- uses: taiki-e/install-action@v2
250+
- name: Install cross
251+
uses: taiki-e/install-action@v2
215252
with:
216253
tool: cross
217254
- name: check
218255
run: cross check -p gix --target ${{ matrix.target }}
219256
- name: Test (unit)
220-
# run high-level unit tests that exercise a lot of code while being pure Rust to ease building test binaries.
221-
# TODO: figure out why `git` doesn't pick up environment configuration so build scripts fail when using `-p gix`.
222-
run: cross test -p gix-hashtable --target ${{ matrix.target }}
257+
run: |
258+
# Run some high-level unit tests that exercise various pure Rust code to ease building test binaries.
259+
# We would prefer `-p gix`. But with `cross`, fixture scripts try to run amd64 `git` as an armv7 binary.
260+
cross test -p gix-hashtable --target ${{ matrix.target }}
223261
224262
lint:
225263
runs-on: ubuntu-latest
@@ -396,6 +434,7 @@ jobs:
396434
- test-journey
397435
- test-fast
398436
- test-32bit
437+
- test-32bit-cross
399438
- lint
400439
- cargo-deny
401440
- check-packetline

Cargo.lock

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gix-archive/tests/archive.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@ mod from_tree {
1414

1515
use crate::hex_to_id;
1616

17+
#[cfg(target_pointer_width = "64")]
18+
const EXPECTED_BUFFER_LENGTH: usize = 551;
19+
#[cfg(target_pointer_width = "32")]
20+
const EXPECTED_BUFFER_LENGTH: usize = 479;
21+
1722
#[test]
1823
fn basic_usage_internal() -> gix_testtools::Result {
1924
basic_usage(gix_archive::Format::InternalTransientNonPersistable, |buf| {
20-
assert_eq!(buf.len(), 551);
25+
assert_eq!(buf.len(), EXPECTED_BUFFER_LENGTH);
2126

2227
let mut stream = gix_worktree_stream::Stream::from_read(std::io::Cursor::new(buf));
2328
let mut paths_and_modes = Vec::new();

gix-attributes/tests/search/mod.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use gix_attributes::{
66
AssignmentRef, NameRef, StateRef,
77
};
88
use gix_glob::pattern::Case;
9+
use gix_testtools::size_ok;
910

1011
mod specials {
1112
use std::path::Path;
@@ -268,10 +269,11 @@ fn given_attributes_are_made_available_in_given_order() -> crate::Result {
268269

269270
#[test]
270271
fn size_of_outcome() {
271-
assert_eq!(
272-
std::mem::size_of::<Outcome>(),
273-
840,
274-
"it's quite big, shouldn't change without us noticing"
272+
let actual = std::mem::size_of::<Outcome>();
273+
let expected = 840;
274+
assert!(
275+
size_ok(actual, expected),
276+
"it's quite big, shouldn't change without us noticing: {actual} <~ {expected}"
275277
);
276278
}
277279

gix-index/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,8 @@ rustix = { version = "0.38.20", default-features = false, features = [
5858
] }
5959
libc = { version = "0.2.149" }
6060

61+
[dev-dependencies]
62+
gix-testtools = { path = "../tests/tools" }
63+
6164
[package.metadata.docs.rs]
6265
features = ["document-features", "serde"]

gix-index/src/extension/tree/mod.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@ mod write;
1313

1414
#[cfg(test)]
1515
mod tests {
16+
use gix_testtools::size_ok;
1617

1718
#[test]
1819
fn size_of_tree() {
19-
assert_eq!(std::mem::size_of::<crate::extension::Tree>(), 88);
20+
let actual = std::mem::size_of::<crate::extension::Tree>();
21+
let expected = 88;
22+
assert!(
23+
size_ok(actual, expected),
24+
"the size of this structure should not change unexpectedly: {actual} <~ {expected}"
25+
);
2026
}
2127
}

gix-index/src/lib.rs

-9
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,3 @@ pub(crate) mod util {
237237
data.split_at(pos).into()
238238
}
239239
}
240-
241-
#[test]
242-
fn size_of_entry() {
243-
assert_eq!(std::mem::size_of::<crate::Entry>(), 80);
244-
245-
// the reason we have our own time is half the size.
246-
assert_eq!(std::mem::size_of::<crate::entry::stat::Time>(), 8);
247-
assert_eq!(std::mem::size_of::<filetime::FileTime>(), 16);
248-
}

gix-index/tests/index/mod.rs

+27-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
use std::path::{Path, PathBuf};
2-
3-
use gix_hash::ObjectId;
4-
51
mod access;
62
mod entry;
73
mod file;
84
mod fs;
95
mod init;
106

7+
use std::path::{Path, PathBuf};
8+
9+
use gix_hash::ObjectId;
10+
use gix_testtools::size_ok;
11+
1112
pub fn hex_to_id(hex: &str) -> ObjectId {
1213
ObjectId::from_hex(hex.as_bytes()).expect("40 bytes hex")
1314
}
@@ -25,11 +26,29 @@ pub fn loose_file_path(name: &str) -> PathBuf {
2526

2627
#[test]
2728
fn size_of_entry() {
28-
assert_eq!(std::mem::size_of::<gix_index::Entry>(), 80);
29+
let actual = std::mem::size_of::<gix_index::Entry>();
30+
let expected = 80;
31+
assert!(
32+
size_ok(actual, expected),
33+
"the size of this structure should not change unexpectedly: {actual} <~ {expected}"
34+
);
35+
}
2936

30-
// the reason we have our own time is half the size.
31-
assert_eq!(std::mem::size_of::<gix_index::entry::stat::Time>(), 8);
32-
assert_eq!(std::mem::size_of::<filetime::FileTime>(), 16);
37+
#[test]
38+
fn size_of_entry_time() {
39+
// The reason we have our own time is that it is half the size.
40+
let ent_actual = std::mem::size_of::<gix_index::entry::stat::Time>();
41+
let ent_expected = 8;
42+
assert!(
43+
size_ok(ent_actual, ent_expected),
44+
"the size of this structure should not change unexpectedly: {ent_actual} <~ {ent_expected}"
45+
);
46+
let ft_actual = std::mem::size_of::<filetime::FileTime>();
47+
let ft_expected = 16;
48+
assert!(
49+
size_ok(ft_actual, ft_expected),
50+
"we will want to know if the size of this structure changes: {ft_actual} <~ {ft_expected}"
51+
);
3352
}
3453

3554
enum Fixture {

gix-negotiate/tests/negotiate.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use gix_testtools::Result;
1+
use gix_testtools::{size_ok, Result};
22

33
mod window_size {
44
use gix_negotiate::window_size;
@@ -38,9 +38,10 @@ mod baseline;
3838

3939
#[test]
4040
fn size_of_entry() {
41-
assert_eq!(
42-
std::mem::size_of::<gix_revwalk::graph::Commit<gix_negotiate::Metadata>>(),
43-
56,
44-
"we may keep a lot of these, so let's not let them grow unnoticed"
41+
let actual = std::mem::size_of::<gix_revwalk::graph::Commit<gix_negotiate::Metadata>>();
42+
let expected = 56;
43+
assert!(
44+
size_ok(actual, expected),
45+
"we may keep a lot of these, so let's not let them grow unnoticed: {actual} <~ {expected}"
4546
);
4647
}

gix-pack/src/cache/delta/mod.rs

-26
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,3 @@ pub mod from_offsets;
2222
mod tree;
2323

2424
pub use tree::{Item, Tree};
25-
26-
#[cfg(test)]
27-
mod tests {
28-
29-
#[test]
30-
fn size_of_pack_tree_item() {
31-
use super::Item;
32-
assert_eq!(std::mem::size_of::<[Item<()>; 7_500_000]>(), 300_000_000);
33-
}
34-
35-
#[test]
36-
fn size_of_pack_verify_data_structure() {
37-
use super::Item;
38-
pub struct EntryWithDefault {
39-
_index_entry: crate::index::Entry,
40-
_kind: gix_object::Kind,
41-
_object_size: u64,
42-
_decompressed_size: u64,
43-
_compressed_size: u64,
44-
_header_size: u16,
45-
_level: u16,
46-
}
47-
48-
assert_eq!(std::mem::size_of::<[Item<EntryWithDefault>; 7_500_000]>(), 840_000_000);
49-
}
50-
}

gix-pack/src/cache/delta/tree.rs

+30-17
Original file line numberDiff line numberDiff line change
@@ -226,25 +226,38 @@ mod tests {
226226
}
227227
}
228228

229-
#[test]
230-
fn size_of_pack_tree_item() {
231-
use super::Item;
232-
assert_eq!(std::mem::size_of::<[Item<()>; 7_500_000]>(), 300_000_000);
233-
}
229+
mod size {
230+
use super::super::Item;
231+
use gix_testtools::size_ok;
234232

235-
#[test]
236-
fn size_of_pack_verify_data_structure() {
237-
use super::Item;
238-
pub struct EntryWithDefault {
239-
_index_entry: crate::index::Entry,
240-
_kind: gix_object::Kind,
241-
_object_size: u64,
242-
_decompressed_size: u64,
243-
_compressed_size: u64,
244-
_header_size: u16,
245-
_level: u16,
233+
#[test]
234+
fn size_of_pack_tree_item() {
235+
let actual = std::mem::size_of::<[Item<()>; 7_500_000]>();
236+
let expected = 300_000_000;
237+
assert!(
238+
size_ok(actual, expected),
239+
"we don't want these to grow unnoticed: {actual} <~ {expected}"
240+
);
246241
}
247242

248-
assert_eq!(std::mem::size_of::<[Item<EntryWithDefault>; 7_500_000]>(), 840_000_000);
243+
#[test]
244+
fn size_of_pack_verify_data_structure() {
245+
pub struct EntryWithDefault {
246+
_index_entry: crate::index::Entry,
247+
_kind: gix_object::Kind,
248+
_object_size: u64,
249+
_decompressed_size: u64,
250+
_compressed_size: u64,
251+
_header_size: u16,
252+
_level: u16,
253+
}
254+
255+
let actual = std::mem::size_of::<[Item<EntryWithDefault>; 7_500_000]>();
256+
let expected = 840_000_000;
257+
assert!(
258+
size_ok(actual, expected),
259+
"we don't want these to grow unnoticed: {actual} <~ {expected}"
260+
);
261+
}
249262
}
250263
}

gix-pack/src/data/file/decode/entry.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -420,13 +420,15 @@ impl File {
420420
#[cfg(test)]
421421
mod tests {
422422
use super::*;
423+
use gix_testtools::size_ok;
423424

424425
#[test]
425426
fn size_of_decode_entry_outcome() {
426-
assert_eq!(
427-
std::mem::size_of::<Outcome>(),
428-
32,
429-
"this shouldn't change without use noticing as it's returned a lot"
427+
let actual = std::mem::size_of::<Outcome>();
428+
let expected = 32;
429+
assert!(
430+
size_ok(actual, expected),
431+
"this shouldn't change without use noticing as it's returned a lot: {actual} <~ {expected}"
430432
);
431433
}
432434
}

gix-pack/tests/pack/data/output/mod.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
use std::{path::PathBuf, sync::Arc};
22

33
use gix_pack::data::output;
4+
use gix_testtools::size_ok;
45

56
#[test]
67
fn size_of_entry() {
7-
assert_eq!(
8-
std::mem::size_of::<output::Entry>(),
9-
80,
10-
"The size of the structure shouldn't change unexpectedly"
8+
let actual = std::mem::size_of::<output::Entry>();
9+
let expected = 80;
10+
assert!(
11+
size_ok(actual, expected),
12+
"The size of the structure shouldn't change unexpectedly: {actual} <~ {expected}"
1113
);
1214
}
1315

1416
#[test]
1517
fn size_of_count() {
16-
assert_eq!(
17-
std::mem::size_of::<output::Count>(),
18-
56,
19-
"The size of the structure shouldn't change unexpectedly"
18+
let actual = std::mem::size_of::<output::Count>();
19+
let expected = 56;
20+
assert!(
21+
size_ok(actual, expected),
22+
"The size of the structure shouldn't change unexpectedly: {actual} <~ {expected}"
2023
);
2124
}
2225

0 commit comments

Comments
 (0)