@@ -43,7 +43,7 @@ fn init_new_project() {
43
43
) ,
44
44
) ;
45
45
46
- validate_init ( & temp. join ( "test_name" ) , false , & Template :: BalanceContract ) ;
46
+ validate_init ( & temp. join ( "test_name" ) , None , & Template :: BalanceContract ) ;
47
47
}
48
48
49
49
#[ test_case( & Template :: CairoProgram ; "cairo-program" ) ]
@@ -66,7 +66,7 @@ fn create_new_project_dir_not_exist(template: &Template) {
66
66
. assert ( )
67
67
. success ( ) ;
68
68
69
- validate_init ( & project_path, false , template) ;
69
+ validate_init ( & project_path, None , template) ;
70
70
}
71
71
72
72
#[ test]
@@ -105,7 +105,7 @@ fn create_new_project_dir_exists_and_empty() {
105
105
. assert ( )
106
106
. success ( ) ;
107
107
108
- validate_init ( & project_path, false , & Template :: BalanceContract ) ;
108
+ validate_init ( & project_path, None , & Template :: BalanceContract ) ;
109
109
}
110
110
111
111
#[ test]
@@ -123,17 +123,49 @@ fn init_new_project_from_scarb() {
123
123
. assert ( )
124
124
. success ( ) ;
125
125
126
- validate_init ( & temp. join ( "test_name" ) , true , & Template :: BalanceContract ) ;
126
+ validate_init (
127
+ & temp. join ( "test_name" ) ,
128
+ Some ( SnforgeStd :: Normal ) ,
129
+ & Template :: BalanceContract ,
130
+ ) ;
127
131
}
128
132
133
+ #[ test]
134
+ #[ cfg_attr( not( feature = "scarb_2_9_1" ) , ignore) ]
135
+ fn init_new_project_from_scarb_snforge_std_compatibility ( ) {
136
+ let temp = tempdir_with_tool_versions ( ) . unwrap ( ) ;
137
+ let tool_version_path = temp. join ( ".tool-versions" ) ;
138
+ fs:: write ( tool_version_path, "scarb 2.11.4" ) . unwrap ( ) ;
139
+
140
+ SnapboxCommand :: new ( "scarb" )
141
+ . current_dir ( & temp)
142
+ . args ( [ "new" , "test_name" ] )
143
+ . env ( "SCARB_INIT_TEST_RUNNER" , "starknet-foundry" )
144
+ . env (
145
+ "PATH" ,
146
+ append_to_path_var ( snforge_test_bin_path ( ) . parent ( ) . unwrap ( ) ) ,
147
+ )
148
+ . assert ( )
149
+ . success ( ) ;
150
+
151
+ validate_init (
152
+ & temp. join ( "test_name" ) ,
153
+ Some ( SnforgeStd :: Compatibility ) ,
154
+ & Template :: BalanceContract ,
155
+ ) ;
156
+ }
129
157
pub fn append_to_path_var ( path : & Path ) -> OsString {
130
158
let script_path = iter:: once ( path. to_path_buf ( ) ) ;
131
159
let os_path = env:: var_os ( "PATH" ) . unwrap ( ) ;
132
160
let other_paths = env:: split_paths ( & os_path) ;
133
161
env:: join_paths ( script_path. chain ( other_paths) ) . unwrap ( )
134
162
}
135
163
136
- fn validate_init ( project_path : & PathBuf , validate_snforge_std : bool , template : & Template ) {
164
+ fn validate_init (
165
+ project_path : & PathBuf ,
166
+ validate_snforge_std : Option < SnforgeStd > ,
167
+ template : & Template ,
168
+ ) {
137
169
let manifest_path = project_path. join ( "Scarb.toml" ) ;
138
170
let scarb_toml = fs:: read_to_string ( manifest_path. clone ( ) ) . unwrap ( ) ;
139
171
@@ -160,7 +192,7 @@ fn validate_init(project_path: &PathBuf, validate_snforge_std: bool, template: &
160
192
dependencies. remove ( "snforge_std" ) ;
161
193
dependencies. insert ( "snforge_std" , Item :: Value ( Value :: InlineTable ( snforge_std) ) ) ;
162
194
163
- std :: fs:: write ( manifest_path, scarb_toml. to_string ( ) ) . unwrap ( ) ;
195
+ fs:: write ( manifest_path, scarb_toml. to_string ( ) ) . unwrap ( ) ;
164
196
165
197
let output = test_runner ( & TempDir :: new ( ) . unwrap ( ) )
166
198
. current_dir ( project_path)
@@ -171,11 +203,21 @@ fn validate_init(project_path: &PathBuf, validate_snforge_std: bool, template: &
171
203
assert_stdout_contains ( output, expected) ;
172
204
}
173
205
174
- fn get_expected_manifest_content ( template : & Template , validate_snforge_std : bool ) -> String {
175
- let snforge_std_assert = if validate_snforge_std {
176
- "\n snforge_std = \" [..]\" "
177
- } else {
178
- ""
206
+ enum SnforgeStd {
207
+ Normal ,
208
+ Compatibility ,
209
+ }
210
+
211
+ fn get_expected_manifest_content (
212
+ template : & Template ,
213
+ validate_snforge_std : Option < SnforgeStd > ,
214
+ ) -> String {
215
+ let snforge_std_assert = match validate_snforge_std {
216
+ None => "" ,
217
+ Some ( snforge_std) => match snforge_std {
218
+ SnforgeStd :: Normal => "\n snforge_std = \" [..]\" " ,
219
+ SnforgeStd :: Compatibility => "\n snforge_std_compatibility = \" [..]\" " ,
220
+ } ,
179
221
} ;
180
222
181
223
let target_contract_entry = "[[target.starknet-contract]]\n sierra = true" ;
0 commit comments