Debian Codegraph @

debian/patches/serialize-global-tests.patch

raw
1 --- rust-mock-instant-0.6.0.orig/src/global.rs
2 +++ rust-mock-instant-0.6.0/src/global.rs
3 @@ -38,11 +38,12 @@ crate::macros::define_system_time! {
4 /// This uses a global mutex for its time source
5 }
6
7 -crate::macros::define_instant_tests!();
8 +crate::macros::define_instant_tests!(let _guard = tests::TESTLOCK.lock());
9
10 #[cfg(test)]
11 mod tests {
12 use super::*;
13 + pub (super) static TESTLOCK: Mutex<()> = Mutex::new(());
14
15 #[test]
16 fn is_thread_local() {
17 @@ -53,6 +54,7 @@ mod tests {
18
19 #[test]
20 fn thread_sharing() {
21 + let _guard = TESTLOCK.lock();
22 MockClock::set_time(Duration::ZERO);
23
24 let start = Instant::now();
25 --- rust-mock-instant-0.6.0.orig/src/macros.rs
26 +++ rust-mock-instant-0.6.0/src/macros.rs
27 @@ -229,7 +229,7 @@ macro_rules! define_system_time {
28 }
29
30 macro_rules! define_instant_tests {
31 - () => {
32 + ($takelock:stmt) => {
33 #[cfg(test)]
34 mod common {
35 use super::*;
36 @@ -244,6 +244,7 @@ macro_rules! define_instant_tests {
37
38 #[test]
39 fn set_system_time() {
40 + $takelock
41 reset_system_time();
42
43 MockClock::set_system_time(Duration::from_secs(42));
44 @@ -255,6 +256,7 @@ macro_rules! define_instant_tests {
45
46 #[test]
47 fn advance_system_time() {
48 + $takelock
49 reset_system_time();
50
51 for i in 0..3 {
52 @@ -266,6 +268,7 @@ macro_rules! define_instant_tests {
53
54 #[test]
55 fn system_time() {
56 + $takelock
57 reset_system_time();
58
59 let now = SystemTime::now();
60 @@ -284,6 +287,7 @@ macro_rules! define_instant_tests {
61
62 #[test]
63 fn system_time_methods() {
64 + $takelock
65 reset_system_time();
66
67 let system_time = SystemTime::now();
68 @@ -329,6 +333,7 @@ macro_rules! define_instant_tests {
69
70 #[test]
71 fn system_time_sub_millisecond_precision() {
72 + $takelock
73 reset_system_time();
74
75 let t1 = SystemTime::UNIX_EPOCH;
76 @@ -343,6 +348,7 @@ macro_rules! define_instant_tests {
77
78 #[test]
79 fn system_time_from_std_roundtrip() {
80 + $takelock
81 let std_now = std::time::SystemTime::now();
82 let mock_now: SystemTime = std_now.into();
83 assert!(mock_now.0 > Duration::from_secs(1708041600)); // Friday 16 February 2024 00:00:00 GMT
84 @@ -352,6 +358,7 @@ macro_rules! define_instant_tests {
85
86 #[test]
87 fn set_time() {
88 + $takelock
89 reset_time();
90
91 MockClock::set_time(Duration::from_secs(42));
92 @@ -363,6 +370,7 @@ macro_rules! define_instant_tests {
93
94 #[test]
95 fn advance() {
96 + $takelock
97 reset_time();
98
99 for i in 0..3 {
100 @@ -374,6 +382,7 @@ macro_rules! define_instant_tests {
101
102 #[test]
103 fn instant() {
104 + $takelock
105 reset_time();
106
107 let now = Instant::now();
108 @@ -389,6 +398,7 @@ macro_rules! define_instant_tests {
109
110 #[test]
111 fn methods() {
112 + $takelock
113 reset_time();
114
115 let instant = Instant::now();
116 @@ -458,6 +468,7 @@ macro_rules! define_instant_tests {
117
118 #[test]
119 fn instant_sub_millisecond_precision() {
120 + $takelock
121 reset_time();
122
123 let t1 = Instant::now();
124 --- rust-mock-instant-0.6.0.orig/src/thread_local.rs
125 +++ rust-mock-instant-0.6.0/src/thread_local.rs
126 @@ -38,7 +38,7 @@ crate::macros::define_system_time! {
127 /// This uses a thread-local cell for its time source
128 }
129
130 -crate::macros::define_instant_tests!();
131 +crate::macros::define_instant_tests!({});
132
133 #[cfg(test)]
134 mod tests {