@@ -5,6 +5,51 @@ use rustwide::cmd::{ProcessLinesActions, SandboxBuilder};
5
5
mod runner;
6
6
mod inside_docker;
7
7
8
+ #[ test]
9
+ fn buildtest_crate_name_matches_folder_name ( ) {
10
+ for result in std:: fs:: read_dir ( concat ! (
11
+ env!( "CARGO_MANIFEST_DIR" ) ,
12
+ "/tests/buildtest/crates"
13
+ ) )
14
+ . unwrap ( )
15
+ {
16
+ let dir_entry = result. unwrap ( ) ;
17
+ if dir_entry. file_type ( ) . unwrap ( ) . is_dir ( ) {
18
+ let dir_name = dir_entry. file_name ( ) ;
19
+
20
+ if [
21
+ "cargo-workspace" . as_ref ( ) ,
22
+ "invalid-cargotoml-syntax" . as_ref ( ) ,
23
+ ]
24
+ . contains ( & dir_name. as_os_str ( ) )
25
+ {
26
+ continue ;
27
+ }
28
+
29
+ let expected_crate_name = if dir_name != "invalid-cargotoml-content" {
30
+ dir_name. clone ( )
31
+ } else {
32
+ "!" . into ( )
33
+ } ;
34
+
35
+ let cargo_toml_path = dir_entry. path ( ) . join ( "Cargo.toml" ) ;
36
+
37
+ if !cargo_toml_path. exists ( ) {
38
+ continue ;
39
+ }
40
+
41
+ let cargo_toml_content = std:: fs:: read_to_string ( & cargo_toml_path) . unwrap ( ) ;
42
+
43
+ assert ! (
44
+ cargo_toml_content. contains( & format!( "name = {expected_crate_name:?}" ) ) ,
45
+ "directory {:?} does not contain a crate with the expected name {:?}" ,
46
+ dir_name,
47
+ expected_crate_name
48
+ )
49
+ }
50
+ }
51
+ }
52
+
8
53
#[ test]
9
54
fn test_hello_world ( ) {
10
55
runner:: run ( "hello-world" , |run| {
@@ -199,7 +244,7 @@ test_prepare_error_stderr!(
199
244
test_missing_deps_git,
200
245
"missing-deps-git" ,
201
246
MissingDependencies ,
202
- "failed to get `not-a-git-repo` as a dependency of package `missing-deps v0.1.0"
247
+ "failed to get `not-a-git-repo` as a dependency of package `missing-deps-git v0.1.0"
203
248
) ;
204
249
205
250
test_prepare_error_stderr ! (
0 commit comments