Translator tests: the profile fingerprint count is per thread
a_run_of_compiles_derives_no_profile_fingerprint reads a count of profile fingerprint derivations. The count was process-wide, so when cargo test ran another test as a thread of the same process and that test made a device between the two readings, this test failed. The count is now thread-local. The device's making and the compiles the test counts run on the test's own thread: compile_stage spawns no thread, and the translator's one scoped thread only hashes a large metallib's bytes. So the count still sees every derivation the test asks about. The change is in a cfg(test) item of device/profile.rs, so no run behaves differently. runtime-sources.sha256 takes the file's new hash. It was computed with the build's hashing over the working tree, which reproduced development's pin before the edit.
This commit is contained in:
1 parent
0801320a59
commit
c20024991d
2 files changed
+11
-6
No files matched your search
@@ -1 +1 @@
|
||||
9679f1c8115f4456e4df7a838d8e2220c07efd615c929eee91c6e5e9ecc85da4
|
||||
48b7912f4dddee80bc4194dde8013d44e17cb6924d2e166efa68792c3a760327
|
||||
@@ -315,22 +315,27 @@ impl DeviceProfile {
|
||||
/// Count one derivation ([`FINGERPRINTS_DERIVED`]).
|
||||
#[cfg(test)]
|
||||
fn note_fingerprint_derived() {
|
||||
FINGERPRINTS_DERIVED.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
||||
FINGERPRINTS_DERIVED.with(|count| count.set(count.get() + 1));
|
||||
}
|
||||
|
||||
/// Count one derivation; nothing outside the crate's own tests.
|
||||
#[cfg(not(test))]
|
||||
fn note_fingerprint_derived() {}
|
||||
|
||||
/// The profile fingerprints derived in this process, which `tests::profile`'s count reads: a
|
||||
/// device's compiles must add none to what its own making derived.
|
||||
/// The profile fingerprints derived on this thread, which `tests::profile_fingerprint_derived`'s
|
||||
/// count reads: a device's compiles must add none to what its own making derived. Per thread,
|
||||
/// because a test harness that runs tests as threads of one process runs others beside it, and
|
||||
/// their devices derive fingerprints of their own; the device's making and its compiles run on
|
||||
/// the test's thread.
|
||||
#[cfg(test)]
|
||||
static FINGERPRINTS_DERIVED: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
|
||||
thread_local! {
|
||||
static FINGERPRINTS_DERIVED: std::cell::Cell<u64> = const { std::cell::Cell::new(0) };
|
||||
}
|
||||
|
||||
/// [`FINGERPRINTS_DERIVED`].
|
||||
#[cfg(test)]
|
||||
pub(crate) fn fingerprints_derived() -> u64 {
|
||||
FINGERPRINTS_DERIVED.load(std::sync::atomic::Ordering::Relaxed)
|
||||
FINGERPRINTS_DERIVED.with(std::cell::Cell::get)
|
||||
}
|
||||
|
||||
/// The fingerprint of `fields` ([`DeviceProfile::fingerprint`]): the rendering streams into the
|
||||
|
||||
Reference in new issue
Block a user