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]
406fn 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 ( ( ) )
0 commit comments