310
310
end
311
311
end
312
312
313
+ using Preferences
313
314
@testset " Artifact Usage" begin
314
315
# Don't use `temp_pkg_dir()` here because we need `Pkg.test()` to run in the
315
316
# same package context as the one we're running in right now. Yes, this pollutes
@@ -426,11 +427,16 @@ end
426
427
wrong_hash = engaged_hash
427
428
end
428
429
429
- withenv (" FLOOBLECRANK" => flooblecrank_status) do
430
- add_this_pkg ()
431
- @test isdir (artifact_path (right_hash))
432
- @test ! isdir (artifact_path (wrong_hash))
433
- end
430
+ # Set the flooblecrank via its preference
431
+ set_preferences! (
432
+ joinpath (ap_path, " LocalPreferences.toml" ),
433
+ " AugmentedPlatform" ,
434
+ " flooblecrank" => flooblecrank_status,
435
+ )
436
+
437
+ add_this_pkg ()
438
+ @test isdir (artifact_path (right_hash))
439
+ @test ! isdir (artifact_path (wrong_hash))
434
440
435
441
# Manual test that artifact is installed by instantiate()
436
442
artifacts_toml = joinpath (ap_path, " Artifacts.toml" )
@@ -465,16 +471,19 @@ end
465
471
Pkg. activate (ap_path)
466
472
@test ! isdir (artifact_path (engaged_hash))
467
473
@test ! isdir (artifact_path (disengaged_hash))
474
+
475
+ # Set the flooblecrank via its preference
476
+ set_preferences! (
477
+ joinpath (ap_path, " LocalPreferences.toml" ),
478
+ " AugmentedPlatform" ,
479
+ " flooblecrank" => " disengaged" ,
480
+ )
468
481
469
- # Instantiate with the environment variable set, but with an explicit
470
- # tag set in the platform object, which overrides.
471
- withenv (" FLOOBLECRANK" => " disengaged" ) do
472
- p = HostPlatform ()
473
- p[" flooblecrank" ] = " engaged"
474
- add_this_pkg (; platform= p)
475
- @test isdir (artifact_path (engaged_hash))
476
- @test ! isdir (artifact_path (disengaged_hash))
477
- end
482
+ p = HostPlatform ()
483
+ p[" flooblecrank" ] = " engaged"
484
+ add_this_pkg (; platform= p)
485
+ @test isdir (artifact_path (engaged_hash))
486
+ @test ! isdir (artifact_path (disengaged_hash))
478
487
end
479
488
480
489
# Also run a test of "cross-installation" use `Pkg.API.instantiate(;platform)`
@@ -487,18 +496,21 @@ end
487
496
@test ! isdir (artifact_path (engaged_hash))
488
497
@test ! isdir (artifact_path (disengaged_hash))
489
498
490
- # Instantiate with the environment variable set, but with an explicit
491
- # tag set in the platform object, which overrides.
492
- withenv (" FLOOBLECRANK" => " disengaged" ) do
493
- add_this_pkg ()
499
+ # Set the flooblecrank via its preference
500
+ set_preferences! (
501
+ joinpath (ap_path, " LocalPreferences.toml" ),
502
+ " AugmentedPlatform" ,
503
+ " flooblecrank" => " disengaged" ,
504
+ )
494
505
495
- p = HostPlatform ()
496
- p[" flooblecrank" ] = " engaged"
497
- Pkg. API. instantiate (; platform= p)
506
+ add_this_pkg ()
498
507
499
- @test isdir (artifact_path (engaged_hash))
500
- @test isdir (artifact_path (disengaged_hash))
501
- end
508
+ p = HostPlatform ()
509
+ p[" flooblecrank" ] = " engaged"
510
+ Pkg. API. instantiate (; platform= p)
511
+
512
+ @test isdir (artifact_path (engaged_hash))
513
+ @test isdir (artifact_path (disengaged_hash))
502
514
end
503
515
end
504
516
0 commit comments