1
1
use assert_cmd:: Command ;
2
2
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
+
3
42
#[ test]
4
43
fn channel_selection ( ) {
5
44
let depot_dir = assert_fs:: TempDir :: new ( ) . unwrap ( ) ;
@@ -141,10 +180,15 @@ fn channel_selection() {
141
180
. failure ( ) ;
142
181
143
182
// 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 ( ) ;
144
187
Command :: cargo_bin ( "juliaup" )
145
188
. unwrap ( )
146
- . arg ( "add" )
147
- . arg ( "release" )
189
+ . arg ( "link" )
190
+ . arg ( "ra" )
191
+ . arg ( linked_julia_version)
148
192
. env ( "JULIA_DEPOT_PATH" , depot_dir. path ( ) )
149
193
. env ( "JULIAUP_DEPOT_PATH" , depot_dir. path ( ) )
150
194
. assert ( )
@@ -161,8 +205,9 @@ fn channel_selection() {
161
205
162
206
Command :: cargo_bin ( "juliaup" )
163
207
. unwrap ( )
164
- . arg ( "add" )
165
- . arg ( "rc" )
208
+ . arg ( "link" )
209
+ . arg ( "rb" )
210
+ . arg ( linked_julia_version)
166
211
. env ( "JULIA_DEPOT_PATH" , depot_dir. path ( ) )
167
212
. env ( "JULIAUP_DEPOT_PATH" , depot_dir. path ( ) )
168
213
. assert ( )
0 commit comments