Skip to content

Commit 00087f3

Browse files
Merge pull request #2280 from golemfactory/kek/fix-ci
Fix CI failing since rustc 1.65.0
2 parents 4229a55 + 732c35e commit 00087f3

4 files changed

Lines changed: 49 additions & 30 deletions

File tree

‎.github/workflows/unit-test.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
name: Unit Tests
1616
env:
1717
# `-D warnings` means any warnings emitted will cause build to fail
18-
RUSTFLAGS: "-D warnings -C opt-level=z -C target-cpu=x86-64 -C debuginfo=1"
18+
RUSTFLAGS: "-C opt-level=z -C target-cpu=x86-64 -C debuginfo=1"
1919
X86_64_PC_WINDOWS_MSVC_OPENSSL_DIR: c:/vcpkg/installed/x64-windows
2020
runs-on: ${{ matrix.os }}
2121
strategy:
@@ -48,7 +48,7 @@ jobs:
4848
uses: actions-rs/cargo@v1
4949
with:
5050
command: clippy
51-
args: --all-targets --all-features --workspace -- -D warnings
51+
args: --all-targets --all-features --workspace
5252

5353
- name: Install openssl ( Windows only )
5454
if: runner.os == 'Windows'

‎Cargo.toml‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,5 +227,9 @@ web3 = { git = "https://github.com/golemfactory/rust-web3", branch = "update_eth
227227

228228
# Speed up builds on macOS (will be default in next rust version probably)
229229
# https://jakedeichert.com/blog/reducing-rust-incremental-compilation-times-on-macos-by-70-percent/
230-
[profile.dev]
231-
split-debuginfo = "unpacked"
230+
#
231+
# TODO: reenable split-debuginfo.
232+
# Commented out split-debuginfo makes Windows builds fail due to "`-Csplit-debuginfo=unpacked` is unstable on this platform."
233+
# This should not be the case (cargo is meant to verify that this option is supported), but it is since version 1.65, I think.
234+
# [profile.dev]
235+
# split-debuginfo = "unpacked"

‎core/market/src/testing/backtrace_util.rs‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn adjust_backtrace_level(frames: &[backtrace::BacktraceFrame]) -> Option<usize>
2121
}
2222

2323
fn get_symbol_at_level(bt: &backtrace::Backtrace, lvl: usize) -> Option<String> {
24-
let frames = &bt.frames();
24+
let frames = bt.frames();
2525
match adjust_backtrace_level(frames) {
2626
Some(adjustment) => {
2727
let frame = &frames[lvl + adjustment];
@@ -34,18 +34,17 @@ fn get_symbol_at_level(bt: &backtrace::Backtrace, lvl: usize) -> Option<String>
3434
None
3535
}
3636

37-
pub fn generate_backtraced_name(level: Option<usize>) -> String {
37+
pub fn generate_backtraced_name(level: Option<usize>) -> Option<String> {
3838
let bt = backtrace::Backtrace::new();
39+
3940
// 0th element should be this function. We'd like to know the caller
40-
if let Some(name) = get_symbol_at_level(&bt, level.unwrap_or(1)) {
41+
let name = get_symbol_at_level(&bt, level.unwrap_or(1));
42+
43+
if let Some(name) = &name {
4144
log::trace!("Generated name: {} level: {:?} BT: {:#?}", name, level, bt);
42-
return name;
45+
} else {
46+
log::warn!("No backtrace support. bt={:#?}", bt);
4347
}
44-
let u4 = uuid::Uuid::new_v4().to_string();
45-
log::error!(
46-
"No backtrace support. Generating default name from UUIDv4. uuid4={}, bt={:#?}",
47-
u4,
48-
bt
49-
);
50-
u4
48+
49+
name
5150
}

‎core/market/src/testing/mock_node.rs‎

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ impl MockNodeKind {
105105
}
106106
}
107107

108-
fn testname_from_backtrace(bn: &str) -> String {
108+
fn testname_from_backtrace(bn: &str) -> Option<String> {
109109
log::info!("Test name to regex match: {}", &bn);
110110
// Extract test name
111-
let captures = Regex::new(r"(.*)::(.*)::.*").unwrap().captures(bn).unwrap();
111+
let captures = Regex::new(r"(.*)::(.*)::.*").unwrap().captures(bn)?;
112112
let filename = captures.get(1).unwrap().as_str().to_string();
113113
let testname = captures.get(2).unwrap().as_str().to_string();
114114

115-
format!("{}.{}", filename, testname)
115+
Some(format!("{}.{}", filename, testname))
116116
}
117117

118118
impl MarketsNetwork {
@@ -122,19 +122,35 @@ impl MarketsNetwork {
122122
pub async fn new(test_name: Option<&str>) -> Self {
123123
std::env::set_var("RUST_LOG", "debug");
124124
let _ = env_logger::builder().try_init();
125-
// level 1 is this function.
126-
// level 2 is <core::future::from_generator::GenFuture<T> as
127-
// core::future::future::Future>::poll::XXX> (async)
128-
// We want to know the caller.
129-
let mut bn = crate::testing::backtrace_util::generate_backtraced_name(Some(3));
130-
// Special case for mac&windows. Tests are run in adifferent way on those systems and we
131-
// have to dive one less level down the stack to find the caller (test_* module).
132-
if !bn.starts_with("test_") {
133-
bn = crate::testing::backtrace_util::generate_backtraced_name(Some(2));
134-
}
135-
bn = testname_from_backtrace(&bn);
136125

137-
let test_name = test_name.unwrap_or(&bn).to_string();
126+
let test_name_from_bt = || {
127+
// level 1 is this function.
128+
// level 2 is <core::future::from_generator::GenFuture<T> as
129+
// core::future::future::Future>::poll::XXX> (async)
130+
// We want to know the caller.
131+
crate::testing::backtrace_util::generate_backtraced_name(Some(3))
132+
.and_then(|name| {
133+
// Special case for mac&windows. Tests are run in adifferent way on those systems and we
134+
// have to dive one less level down the stack to find the caller (test_* module).
135+
if !name.starts_with("test_") {
136+
crate::testing::backtrace_util::generate_backtraced_name(Some(2))
137+
} else {
138+
Some(name)
139+
}
140+
})
141+
.as_deref()
142+
.and_then(testname_from_backtrace)
143+
};
144+
145+
let unknown_test_name = || {
146+
let nonce = rand::random::<u128>();
147+
format!("unknown-test-{:#32x}", nonce)
148+
};
149+
150+
let test_name = test_name
151+
.map(String::from)
152+
.or_else(test_name_from_bt)
153+
.unwrap_or_else(unknown_test_name);
138154
log::info!("Intializing MarketsNetwork. tn={}", test_name);
139155

140156
MockNet::default().bind_gsb();

0 commit comments

Comments
 (0)