11use assert_cmd:: Command ;
22
3+ use anyhow:: Result ;
4+ use juliaup:: config_file:: { load_config_db, JuliaupConfigChannel } ;
5+ use juliaup:: global_paths:: get_paths_from_home_path;
6+ use normpath:: PathExt ;
7+ use std:: path:: PathBuf ;
8+
9+ // Simpler reimplementation of get_julia_path_from_channel from julialauncher.rs to help link channels
10+ fn get_julia_path_from_channel (
11+ requested_channel : & str ,
12+ juliaup_depot_path : PathBuf ,
13+ ) -> Result < PathBuf > {
14+ let paths = get_paths_from_home_path ( juliaup_depot_path) ?;
15+ let config_file = load_config_db ( & paths) ?;
16+ let config_data = config_file. data ;
17+
18+ let juliaupconfig_path = paths. juliaupconfig . as_path ( ) ;
19+
20+ let channel_info = config_data
21+ . installed_channels
22+ . get ( requested_channel)
23+ . unwrap ( ) ;
24+
25+ let path: & String = if let JuliaupConfigChannel :: SystemChannel { version } = channel_info {
26+ & config_data. installed_versions . get ( version) . unwrap ( ) . path
27+ } else {
28+ panic ! ( "whoops" )
29+ } ;
30+
31+ let absolute_path = juliaupconfig_path
32+ . parent ( )
33+ . unwrap ( ) // unwrap OK because there should always be a parent
34+ . join ( path)
35+ . join ( "bin" )
36+ . join ( format ! ( "julia{}" , std:: env:: consts:: EXE_SUFFIX ) )
37+ . normalize ( ) ?;
38+
39+ return Ok ( absolute_path. into_path_buf ( ) ) ;
40+ }
41+
342#[ test]
443fn channel_selection ( ) {
544 let depot_dir = assert_fs:: TempDir :: new ( ) . unwrap ( ) ;
@@ -141,10 +180,15 @@ fn channel_selection() {
141180 . failure ( ) ;
142181
143182 // Test that completion works only when it should for words
183+ let linked_julia_path =
184+ get_julia_path_from_channel ( "1.6.7" , depot_dir. path ( ) . to_path_buf ( ) . join ( "juliaup" ) )
185+ . unwrap ( ) ;
186+ let linked_julia_version = linked_julia_path. to_str ( ) . unwrap ( ) ;
144187 Command :: cargo_bin ( "juliaup" )
145188 . unwrap ( )
146- . arg ( "add" )
147- . arg ( "release" )
189+ . arg ( "link" )
190+ . arg ( "ra" )
191+ . arg ( linked_julia_version)
148192 . env ( "JULIA_DEPOT_PATH" , depot_dir. path ( ) )
149193 . env ( "JULIAUP_DEPOT_PATH" , depot_dir. path ( ) )
150194 . assert ( )
@@ -161,8 +205,9 @@ fn channel_selection() {
161205
162206 Command :: cargo_bin ( "juliaup" )
163207 . unwrap ( )
164- . arg ( "add" )
165- . arg ( "rc" )
208+ . arg ( "link" )
209+ . arg ( "rb" )
210+ . arg ( linked_julia_version)
166211 . env ( "JULIA_DEPOT_PATH" , depot_dir. path ( ) )
167212 . env ( "JULIAUP_DEPOT_PATH" , depot_dir. path ( ) )
168213 . assert ( )
0 commit comments