@@ -929,3 +929,123 @@ fn check_conda_prefix_var_to_resolve_path() -> anyhow::Result<()> {
929929
930930 Ok ( ( ) )
931931}
932+
933+ #[ test]
934+ fn src_root_deprecation_warning ( ) -> anyhow:: Result < ( ) > {
935+ let case = CliTest :: with_files ( [
936+ (
937+ "pyproject.toml" ,
938+ r#"
939+ [tool.ty.src]
940+ root = "./src"
941+ "# ,
942+ ) ,
943+ ( "src/test.py" , "" ) ,
944+ ] ) ?;
945+
946+ assert_cmd_snapshot ! ( case. command( ) , @r#"
947+ success: true
948+ exit_code: 0
949+ ----- stdout -----
950+ warning[deprecated-setting]: The `src.root` setting is deprecated. Use `environment.root` instead.
951+ --> pyproject.toml:3:8
952+ |
953+ 2 | [tool.ty.src]
954+ 3 | root = "./src"
955+ | ^^^^^^^
956+ |
957+
958+ Found 1 diagnostic
959+
960+ ----- stderr -----
961+ WARN ty is pre-release software and not ready for production use. Expect to encounter bugs, missing features, and fatal errors.
962+ "# ) ;
963+
964+ Ok ( ( ) )
965+ }
966+
967+ #[ test]
968+ fn src_root_deprecation_warning_with_environment_root ( ) -> anyhow:: Result < ( ) > {
969+ let case = CliTest :: with_files ( [
970+ (
971+ "pyproject.toml" ,
972+ r#"
973+ [tool.ty.src]
974+ root = "./src"
975+
976+ [tool.ty.environment]
977+ root = "./app"
978+ "# ,
979+ ) ,
980+ ( "app/test.py" , "" ) ,
981+ ] ) ?;
982+
983+ assert_cmd_snapshot ! ( case. command( ) , @r#"
984+ success: true
985+ exit_code: 0
986+ ----- stdout -----
987+ warning[deprecated-setting]: The `src.root` setting is deprecated. Use `environment.root` instead.
988+ --> pyproject.toml:3:8
989+ |
990+ 2 | [tool.ty.src]
991+ 3 | root = "./src"
992+ | ^^^^^^^
993+ 4 |
994+ 5 | [tool.ty.environment]
995+ |
996+ info: The `src.root` setting was ignored in favor of the `environment.root` setting
997+
998+ Found 1 diagnostic
999+
1000+ ----- stderr -----
1001+ WARN ty is pre-release software and not ready for production use. Expect to encounter bugs, missing features, and fatal errors.
1002+ "# ) ;
1003+
1004+ Ok ( ( ) )
1005+ }
1006+
1007+ #[ test]
1008+ fn environment_root_takes_precedence_over_src_root ( ) -> anyhow:: Result < ( ) > {
1009+ let case = CliTest :: with_files ( [
1010+ (
1011+ "pyproject.toml" ,
1012+ r#"
1013+ [tool.ty.src]
1014+ root = "./src"
1015+
1016+ [tool.ty.environment]
1017+ root = "./app"
1018+ "# ,
1019+ ) ,
1020+ ( "src/test.py" , "import my_module" ) ,
1021+ (
1022+ "app/my_module.py" ,
1023+ "# This module exists in app/ but not src/" ,
1024+ ) ,
1025+ ] ) ?;
1026+
1027+ // The test should pass because environment.root points to ./app where my_module.py exists
1028+ // If src.root took precedence, it would fail because my_module.py doesn't exist in ./src
1029+ assert_cmd_snapshot ! ( case. command( ) , @r#"
1030+ success: true
1031+ exit_code: 0
1032+ ----- stdout -----
1033+ warning[deprecated-setting]: The `src.root` setting is deprecated. Use `environment.root` instead.
1034+ --> pyproject.toml:3:8
1035+ |
1036+ 2 | [tool.ty.src]
1037+ 3 | root = "./src"
1038+ | ^^^^^^^
1039+ 4 |
1040+ 5 | [tool.ty.environment]
1041+ |
1042+ info: The `src.root` setting was ignored in favor of the `environment.root` setting
1043+
1044+ Found 1 diagnostic
1045+
1046+ ----- stderr -----
1047+ WARN ty is pre-release software and not ready for production use. Expect to encounter bugs, missing features, and fatal errors.
1048+ "# ) ;
1049+
1050+ Ok ( ( ) )
1051+ }
0 commit comments