@@ -2,6 +2,7 @@ use std::process::Command;
2
2
3
3
use assert_fs:: { assert:: PathAssert , prelude:: PathChild } ;
4
4
use predicates:: prelude:: predicate;
5
+ use same_file:: is_same_file;
5
6
6
7
use crate :: common:: { uv_snapshot, TestContext } ;
7
8
@@ -290,6 +291,21 @@ fn python_install_invalid_request() {
290
291
fn python_install_default ( ) {
291
292
let context: TestContext = TestContext :: new_with_versions ( & [ ] ) . with_filtered_python_keys ( ) ;
292
293
294
+ let bin_python_minor = context
295
+ . temp_dir
296
+ . child ( "bin" )
297
+ . child ( format ! ( "python3.13{}" , std:: env:: consts:: EXE_SUFFIX ) ) ;
298
+
299
+ let bin_python_major = context
300
+ . temp_dir
301
+ . child ( "bin" )
302
+ . child ( format ! ( "python3{}" , std:: env:: consts:: EXE_SUFFIX ) ) ;
303
+
304
+ let bin_python_default = context
305
+ . temp_dir
306
+ . child ( "bin" )
307
+ . child ( format ! ( "python{}" , std:: env:: consts:: EXE_SUFFIX ) ) ;
308
+
293
309
// `--preview` is required for `--default`
294
310
uv_snapshot ! ( context. filters( ) , context. python_install( ) . arg( "--default" ) , @r###"
295
311
success: false
@@ -300,51 +316,69 @@ fn python_install_default() {
300
316
The `--default` flag is only available in preview mode; add the `--preview` flag to use `--default.
301
317
"### ) ;
302
318
303
- // Install the latest version
304
- uv_snapshot ! ( context. filters( ) , context. python_install( ) . arg( "--preview" ) , @r###"
319
+ // Install a specific version
320
+ uv_snapshot ! ( context. filters( ) , context. python_install( ) . arg( "--preview" ) . arg ( "3.13" ) , @r###"
305
321
success: true
306
322
exit_code: 0
307
323
----- stdout -----
308
324
309
325
----- stderr -----
310
- Searching for Python installations
311
326
Installed Python 3.13.0 in [TIME]
312
327
+ cpython-3.13.[X]-[PLATFORM]
313
328
warning: `[TEMP_DIR]/bin` is not on your PATH. To use the installed Python executable, run `export PATH="[TEMP_DIR]/bin:$PATH"`.
314
329
"### ) ;
315
330
316
- let bin_python_minor = context
317
- . temp_dir
318
- . child ( "bin" )
319
- . child ( format ! ( "python3.13{}" , std :: env :: consts :: EXE_SUFFIX ) ) ;
331
+ // Only the minor versioned executable should be installed
332
+ bin_python_minor . assert ( predicate :: path :: exists ( ) ) ;
333
+ bin_python_major . assert ( predicate :: path :: missing ( ) ) ;
334
+ bin_python_default . assert ( predicate :: path :: missing ( ) ) ;
320
335
321
- let bin_python_major = context
322
- . temp_dir
323
- . child ( "bin" )
324
- . child ( format ! ( "python3{}" , std:: env:: consts:: EXE_SUFFIX ) ) ;
336
+ // Install again, with `--default`
337
+ uv_snapshot ! ( context. filters( ) , context. python_install( ) . arg( "--preview" ) . arg( "--default" ) . arg( "3.13" ) , @r###"
338
+ success: true
339
+ exit_code: 0
340
+ ----- stdout -----
325
341
326
- let bin_python_default = context
327
- . temp_dir
328
- . child ( "bin" )
329
- . child ( format ! ( "python{}" , std:: env:: consts:: EXE_SUFFIX ) ) ;
342
+ ----- stderr -----
343
+ Installed Python 3.13.0 in [TIME]
344
+ + cpython-3.13.[X]-[PLATFORM]
345
+ warning: `[TEMP_DIR]/bin` is not on your PATH. To use the installed Python executable, run `export PATH="[TEMP_DIR]/bin:$PATH"`.
346
+ "### ) ;
330
347
331
- // The minor-versioend executable should be installed in the bin directory
348
+ // Now all the executables should be installed
332
349
bin_python_minor. assert ( predicate:: path:: exists ( ) ) ;
333
- // But the others should not
350
+ bin_python_major. assert ( predicate:: path:: exists ( ) ) ;
351
+ bin_python_default. assert ( predicate:: path:: exists ( ) ) ;
352
+
353
+ uv_snapshot ! ( context. filters( ) , context. python_uninstall( ) . arg( "--all" ) , @r###"
354
+ success: true
355
+ exit_code: 0
356
+ ----- stdout -----
357
+
358
+ ----- stderr -----
359
+ Searching for Python installations
360
+ Uninstalled Python 3.13.0 in [TIME]
361
+ - cpython-3.13.[X]-[PLATFORM]
362
+ "### ) ;
363
+
364
+ // The executables should be removed
365
+ bin_python_minor. assert ( predicate:: path:: missing ( ) ) ;
334
366
bin_python_major. assert ( predicate:: path:: missing ( ) ) ;
335
367
bin_python_default. assert ( predicate:: path:: missing ( ) ) ;
336
368
337
- // TODO(zanieb): We should add the executables without the `--reinstall` flag
338
- uv_snapshot ! ( context. filters( ) , context. python_install( ) . arg( "--default" ) . arg ( "--reinstall ") , @r###"
339
- success: false
340
- exit_code: 1
369
+ // Install the latest version
370
+ uv_snapshot ! ( context. filters( ) , context. python_install( ) . arg( "--preview " ) , @r###"
371
+ success: true
372
+ exit_code: 0
341
373
----- stdout -----
342
374
343
375
----- stderr -----
344
- The `--default` flag is only available in preview mode; add the `--preview` flag to use `--default.
376
+ Installed Python 3.13.0 in [TIME]
377
+ + cpython-3.13.[X]-[PLATFORM]
378
+ warning: `[TEMP_DIR]/bin` is not on your PATH. To use the installed Python executable, run `export PATH="[TEMP_DIR]/bin:$PATH"`.
345
379
"### ) ;
346
380
347
- // Now we should have an unversioned and major-versioned executable
381
+ // Since it's a bare install, we should include all of the executables
348
382
bin_python_minor. assert ( predicate:: path:: exists ( ) ) ;
349
383
bin_python_major. assert ( predicate:: path:: exists ( ) ) ;
350
384
bin_python_default. assert ( predicate:: path:: exists ( ) ) ;
@@ -366,26 +400,28 @@ fn python_install_default() {
366
400
bin_python_default. assert ( predicate:: path:: missing ( ) ) ;
367
401
368
402
// Install multiple versions
369
- uv_snapshot ! ( context. filters( ) , context. python_install( ) . arg( "3.12" ) . arg( "3.13" ) . arg( "--default" ) , @r###"
370
- success: false
371
- exit_code: 1
403
+ uv_snapshot ! ( context. filters( ) , context. python_install( ) . arg( "--preview" ) . arg ( " 3.12") . arg( "3.13" ) . arg( "--default" ) , @r###"
404
+ success: true
405
+ exit_code: 0
372
406
----- stdout -----
373
407
374
408
----- stderr -----
375
- Searching for Python versions matching: Python 3.12
376
- Searching for Python versions matching: Python 3.13
377
409
Installed 2 versions in [TIME]
378
410
+ cpython-3.12.[X]-[PLATFORM]
379
411
+ cpython-3.13.[X]-[PLATFORM]
380
412
warning: `[TEMP_DIR]/bin` is not on your PATH. To use the installed Python executable, run `export PATH="[TEMP_DIR]/bin:$PATH"`.
381
- error: Failed to install cpython-3.12.[X]-[PLATFORM]
382
- Caused by: Executable already exists at `bin/python3`. Use `--reinstall` to force replacement.
383
- error: Failed to install cpython-3.12.[X]-[PLATFORM]
384
- Caused by: Executable already exists at `bin/python`. Use `--reinstall` to force replacement.
385
413
"### ) ;
386
414
387
415
bin_python_minor. assert ( predicate:: path:: exists ( ) ) ;
388
416
bin_python_major. assert ( predicate:: path:: exists ( ) ) ;
389
417
bin_python_default. assert ( predicate:: path:: exists ( ) ) ;
390
- // TODO(zanieb): Assert that 3.12 is the default version
418
+
419
+ let bin_python_minor_12 = context
420
+ . temp_dir
421
+ . child ( "bin" )
422
+ . child ( format ! ( "python3.12{}" , std:: env:: consts:: EXE_SUFFIX ) ) ;
423
+
424
+ bin_python_minor_12. assert ( predicate:: path:: exists ( ) ) ;
425
+ assert ! ( is_same_file( & bin_python_minor_12, & bin_python_major) . unwrap( ) ) ;
426
+ assert ! ( is_same_file( & bin_python_minor_12, & bin_python_default) . unwrap( ) ) ;
391
427
}
0 commit comments