@@ -77,6 +77,69 @@ async fn test_nested_local(#[values(OutputType::Wasm, OutputType::Wit)] output:
7777 ) ;
7878}
7979
80+ #[ rstest]
81+ #[ tokio:: test]
82+ async fn test_transitive_local ( #[ values( OutputType :: Wasm , OutputType :: Wit ) ] output : OutputType ) {
83+ let ( _temp, fixture_path) = common:: load_fixture ( "transitive-local" ) . await . unwrap ( ) ;
84+ let project_path = fixture_path. join ( "example-a" ) ;
85+ let lock_file = project_path. join ( "wkg.lock" ) ;
86+ let mut lock = LockFile :: new_with_path ( [ ] , & lock_file)
87+ . await
88+ . expect ( "Should be able to create a new lock file" ) ;
89+ // ```toml
90+ // [overrides]
91+ // "example-b:bar" = { "path" = "../example-b/wit" }
92+ // "example-c:baz" = { "path" = "../example-c/wit" }
93+ // ```
94+ let config = Config {
95+ overrides : Some ( HashMap :: from ( [
96+ (
97+ "example-b:bar" . to_string ( ) ,
98+ Override {
99+ path : Some ( fixture_path. join ( "example-b" ) . join ( "wit" ) ) ,
100+ version : None ,
101+ } ,
102+ ) ,
103+ (
104+ "example-c:baz" . to_string ( ) ,
105+ Override {
106+ path : Some ( fixture_path. join ( "example-c" ) . join ( "wit" ) ) ,
107+ version : None ,
108+ } ,
109+ ) ,
110+ ] ) ) ,
111+ ..Default :: default ( )
112+ } ;
113+ let ( _temp_cache, client) = common:: get_client ( ) . await . unwrap ( ) ;
114+
115+ assert ! (
116+ // If overrides didn't properly resolve, this will fail
117+ wit:: fetch_dependencies( & config, project_path. join( "wit" ) , & mut lock, client, output)
118+ . await
119+ . is_ok( ) ,
120+ "Should be able to fetch the dependencies"
121+ ) ;
122+
123+ // Ensure that the deps directory contains the correct dependencies
124+ let mut deps_dir = tokio:: fs:: read_dir ( project_path. join ( "wit" ) . join ( "deps" ) )
125+ . await
126+ . expect ( "Should be able to read the deps directory" ) ;
127+ let mut deps = Vec :: new ( ) ;
128+ while let Ok ( Some ( entry) ) = deps_dir. next_entry ( ) . await {
129+ deps. push ( entry. file_name ( ) . to_string_lossy ( ) . to_string ( ) ) ;
130+ }
131+ assert_eq ! ( deps. len( ) , 2 ) ;
132+ assert ! ( deps. contains( & "example-b-bar-0.1.0" . to_string( ) ) ) ;
133+ assert ! ( deps. contains( & "example-c-baz-0.1.0" . to_string( ) ) ) ;
134+
135+ // All dependencies are local, so the lock file should be empty
136+ assert_eq ! (
137+ lock. packages. len( ) ,
138+ 0 ,
139+ "Should have the correct number of packages in the lock file"
140+ ) ;
141+ }
142+
80143async fn build_component ( fixture_path : & Path ) {
81144 let output = Command :: new ( env ! ( "CARGO" ) )
82145 . current_dir ( fixture_path)
0 commit comments