@@ -1180,6 +1180,102 @@ fn build_no_build_logs() -> Result<()> {
11801180 Ok ( ( ) )
11811181}
11821182
1183+ /// Test that `UV_HIDE_BUILD_OUTPUT` suppresses build output.
1184+ #[ test]
1185+ fn build_hide_build_output_env_var ( ) -> Result < ( ) > {
1186+ let context = TestContext :: new ( "3.12" ) ;
1187+
1188+ let project = context. temp_dir . child ( "project" ) ;
1189+
1190+ let pyproject_toml = project. child ( "pyproject.toml" ) ;
1191+ pyproject_toml. write_str (
1192+ r#"
1193+ [project]
1194+ name = "project"
1195+ version = "0.1.0"
1196+ requires-python = ">=3.12"
1197+ dependencies = ["anyio==3.7.0"]
1198+
1199+ [build-system]
1200+ requires = ["hatchling"]
1201+ build-backend = "hatchling.build"
1202+ "# ,
1203+ ) ?;
1204+
1205+ project
1206+ . child ( "src" )
1207+ . child ( "project" )
1208+ . child ( "__init__.py" )
1209+ . touch ( ) ?;
1210+ project. child ( "README" ) . touch ( ) ?;
1211+
1212+ uv_snapshot ! ( & context. filters( ) , context. build( ) . arg( "project" ) . env( EnvVars :: UV_HIDE_BUILD_OUTPUT , "1" ) , @r###"
1213+ success: true
1214+ exit_code: 0
1215+ ----- stdout -----
1216+
1217+ ----- stderr -----
1218+ Building source distribution...
1219+ Building wheel from source distribution...
1220+ Successfully built project/dist/project-0.1.0.tar.gz
1221+ Successfully built project/dist/project-0.1.0-py3-none-any.whl
1222+ "### ) ;
1223+
1224+ Ok ( ( ) )
1225+ }
1226+
1227+ /// Test that `UV_HIDE_BUILD_OUTPUT` hides build output even on failure.
1228+ #[ test]
1229+ fn build_hide_build_output_on_failure ( ) -> Result < ( ) > {
1230+ let context = TestContext :: new ( "3.12" ) ;
1231+ let filters = context
1232+ . filters ( )
1233+ . into_iter ( )
1234+ . chain ( [ ( r"\\\." , "" ) ] )
1235+ . collect :: < Vec < _ > > ( ) ;
1236+
1237+ let project = context. temp_dir . child ( "project" ) ;
1238+
1239+ let pyproject_toml = project. child ( "pyproject.toml" ) ;
1240+ pyproject_toml. write_str (
1241+ r#"
1242+ [project]
1243+ name = "project"
1244+ version = "0.1.0"
1245+ requires-python = ">=3.12"
1246+
1247+ [build-system]
1248+ requires = ["setuptools"]
1249+ build-backend = "setuptools.build_meta"
1250+ "# ,
1251+ ) ?;
1252+
1253+ // Create a `setup.py` that prints an environment variable before failing.
1254+ project. child ( "setup.py" ) . write_str ( indoc ! { r#"
1255+ import os
1256+ import sys
1257+ print("FOO=" + os.environ.get("FOO", "not-set"), file=sys.stderr)
1258+ sys.stderr.flush()
1259+ raise Exception("Build failed intentionally!")
1260+ "# } ) ?;
1261+
1262+ // With `UV_HIDE_BUILD_OUTPUT`, the output is hidden even on failure.
1263+ uv_snapshot ! ( & filters, context. build( ) . arg( "project" ) . env( EnvVars :: UV_HIDE_BUILD_OUTPUT , "1" ) . env( "FOO" , "bar" ) , @r###"
1264+ success: false
1265+ exit_code: 2
1266+ ----- stdout -----
1267+
1268+ ----- stderr -----
1269+ Building source distribution...
1270+ × Failed to build `[TEMP_DIR]/project`
1271+ ├─▶ The build backend returned an error
1272+ ╰─▶ Call to `setuptools.build_meta.build_sdist` failed (exit status: 1)
1273+ hint: This usually indicates a problem with the package or the build environment.
1274+ "### ) ;
1275+
1276+ Ok ( ( ) )
1277+ }
1278+
11831279#[ test]
11841280fn build_tool_uv_sources ( ) -> Result < ( ) > {
11851281 let context = TestContext :: new ( "3.12" ) ;
0 commit comments