@@ -6,14 +6,14 @@ use cargo::{
66 ops:: CompileOptions ,
77 GlobalContext ,
88} ;
9- use cargo_test_support:: compare;
109use cargo_test_support:: paths:: { root, CargoPathExt } ;
1110use cargo_test_support:: registry:: Package ;
12- use cargo_test_support:: tools;
1311use cargo_test_support:: {
1412 basic_bin_manifest, basic_lib_manifest, basic_manifest, cargo_exe, git, is_nightly, main_file,
1513 paths, process, project, rustc_host, sleep_ms, symlink_supported, t, Execs , ProjectBuilder ,
1614} ;
15+ use cargo_test_support:: { cargo_process, compare} ;
16+ use cargo_test_support:: { git_process, tools} ;
1717use cargo_util:: paths:: dylib_path_envvar;
1818use std:: env;
1919use std:: fs;
@@ -33,6 +33,58 @@ fn cargo_compile_simple() {
3333 p. process ( & p. bin ( "foo" ) ) . with_stdout ( "i am foo\n " ) . run ( ) ;
3434}
3535
36+ #[ cargo_test]
37+ fn build_with_symlink_to_path_dependency_with_build_script_in_git ( ) {
38+ if !symlink_supported ( ) {
39+ return ;
40+ }
41+
42+ let root = paths:: root ( ) ;
43+ git:: repo ( & root)
44+ . nocommit_file (
45+ "Cargo.toml" ,
46+ r#"
47+ [package]
48+ name = "foo"
49+ version = "0.1.0"
50+ edition = "2021"
51+
52+ [dependencies]
53+ # the path leads through a symlink, 'symlink-to-original' is a worktree root,
54+ # and symlink-to-dir/ is a symlink to a sub-directory to be stepped through.
55+ lib = { version = "0.1.0", path = "symlink-to-original/symlink-to-dir/lib" }
56+ "# ,
57+ )
58+ . nocommit_file ( "src/main.rs" , "fn main() { }" )
59+ . nocommit_file ( "original/dir/lib/build.rs" , "fn main() {}" )
60+ . nocommit_file (
61+ "original/dir/lib/Cargo.toml" ,
62+ r#"
63+ [package]
64+ name = "lib"
65+ version = "0.1.0"
66+ edition = "2021"
67+ "# ,
68+ )
69+ . nocommit_file ( "original/dir/lib/src/lib.rs" , "" )
70+ . nocommit_symlink_dir ( "original" , "symlink-to-original" )
71+ . nocommit_symlink_dir ( "original/dir" , "original/symlink-to-dir" )
72+ . build ( ) ;
73+
74+ // It is necessary to have a sub-repository and to add files so there is an index.
75+ git_process ( "init" )
76+ . cwd ( root. join ( "original" ) )
77+ . build_command ( )
78+ . status ( )
79+ . unwrap ( ) ;
80+ git_process ( "add ." )
81+ . cwd ( root. join ( "original" ) )
82+ . build_command ( )
83+ . status ( )
84+ . unwrap ( ) ;
85+ cargo_process ( "build" ) . run ( )
86+ }
87+
3688#[ cargo_test]
3789fn cargo_fail_with_no_stderr ( ) {
3890 let p = project ( )
0 commit comments