Skip to content

Commit 846897a

Browse files
committed
Fix deptree_snapshot
1 parent 15fd0c7 commit 846897a

2 files changed

Lines changed: 14 additions & 44 deletions

File tree

crates/bindings/tests/deps.rs

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,12 @@
22
//! to make sure we don't unknowingly add a bunch of dependencies here,
33
//! slowing down compilation for every spacetime module.
44
5-
// We need to remove the `cpufeatures` and `libc` dependencies from the output, it added on `arm` architecture:
6-
// https://github.com/RustCrypto/sponges/blob/master/keccak/Cargo.toml#L24-L25, breaking local testing.
7-
#[cfg(target_arch = "aarch64")]
8-
fn hack_keccack(cmd: String) -> String {
9-
let mut found = false;
10-
let mut lines = cmd.lines().peekable();
11-
let mut output = String::new();
12-
13-
while let Some(line) = lines.next() {
14-
// Check we only match keccak/cpufeatures/libc
15-
if line.contains("keccak") {
16-
found = true;
17-
}
18-
if found && line.contains("cpufeatures") {
19-
if let Some(next_line) = lines.peek() {
20-
if next_line.contains("libc") {
21-
found = false;
22-
// Skip libc
23-
lines.next();
24-
continue;
25-
}
26-
}
27-
}
28-
output.push_str(line);
29-
output.push('\n');
30-
}
31-
32-
output
33-
}
34-
#[cfg(not(target_arch = "aarch64"))]
35-
fn hack_keccack(cmd: String) -> String {
36-
cmd
37-
}
38-
395
#[test]
406
fn deptree_snapshot() -> std::io::Result<()> {
41-
let cmd = "cargo tree -p spacetimedb -f {lib} -e no-dev";
42-
let deps_tree = hack_keccack(run_cmd(cmd));
43-
let all_deps = hack_keccack(run_cmd("cargo tree -p spacetimedb -e no-dev --prefix none --no-dedupe"));
7+
let cmd_common = "cargo tree -p spacetimedb -e no-dev --color never --target wasm32-unknown-unknown";
8+
let cmd = &format!("{cmd_common} -f {{lib}}");
9+
let deps_tree = run_cmd(cmd);
10+
let all_deps = run_cmd(&format!("{cmd_common} --prefix none --no-dedupe"));
4411
let mut all_deps = all_deps.lines().collect::<Vec<_>>();
4512
all_deps.sort();
4613
all_deps.dedup();
@@ -52,7 +19,7 @@ fn deptree_snapshot() -> std::io::Result<()> {
5219
cmd
5320
);
5421

55-
let cmd = "cargo tree -p spacetimedb -e no-dev -d --depth 0";
22+
let cmd = &format!("{cmd_common} -d --depth 0");
5623
insta::assert_snapshot!("duplicate_deps", run_cmd(cmd), cmd);
5724

5825
Ok(())

crates/bindings/tests/snapshots/deps__spacetimedb_bindings_dependencies.snap

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
source: crates/bindings/tests/deps.rs
3-
expression: "cargo tree -p spacetimedb -f {lib} -e no-dev"
3+
expression: "cargo tree -p spacetimedb -e no-dev --color never --target wasm32-unknown-unknown -f {lib}"
44
---
5-
total crates: 66
5+
total crates: 65
66
spacetimedb
77
├── bytemuck
88
├── derive_more
@@ -19,11 +19,9 @@ spacetimedb
1919
│ └── rustc_version
2020
│ └── semver
2121
├── getrandom
22-
│ ├── cfg_if
23-
│ └── libc
22+
│ └── cfg_if
2423
├── log
2524
├── rand
26-
│ ├── libc
2725
│ ├── rand_chacha
2826
│ │ ├── ppv_lite86
2927
│ │ │ └── zerocopy
@@ -44,7 +42,12 @@ spacetimedb
4442
│ │ └── nohash_hasher
4543
│ └── syn (*)
4644
├── spacetimedb_bindings_sys
47-
│ └── spacetimedb_primitives (*)
45+
│ └── spacetimedb_primitives
46+
│ ├── bitflags
47+
│ ├── either
48+
│ ├── itertools
49+
│ │ └── either
50+
│ └── nohash_hasher
4851
├── spacetimedb_lib
4952
│ ├── anyhow
5053
│ ├── bitflags

0 commit comments

Comments
 (0)