Skip to content

Commit 7e35995

Browse files
chansukepetrochenkov
authored andcommitted
Separate librustc_codegen_ssa module
1 parent ed54d10 commit 7e35995

File tree

2 files changed

+94
-95
lines changed

2 files changed

+94
-95
lines changed

src/librustc_codegen_ssa/back/rpath.rs

Lines changed: 1 addition & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -173,98 +173,4 @@ fn minimize_rpaths(rpaths: &[String]) -> Vec<String> {
173173
}
174174

175175
#[cfg(all(unix, test))]
176-
mod tests {
177-
use super::{RPathConfig};
178-
use super::{minimize_rpaths, rpaths_to_flags, get_rpath_relative_to_output};
179-
use std::path::{Path, PathBuf};
180-
181-
#[test]
182-
fn test_rpaths_to_flags() {
183-
let flags = rpaths_to_flags(&[
184-
"path1".to_string(),
185-
"path2".to_string()
186-
]);
187-
assert_eq!(flags,
188-
["-Wl,-rpath,path1",
189-
"-Wl,-rpath,path2"]);
190-
}
191-
192-
#[test]
193-
fn test_minimize1() {
194-
let res = minimize_rpaths(&[
195-
"rpath1".to_string(),
196-
"rpath2".to_string(),
197-
"rpath1".to_string()
198-
]);
199-
assert!(res == [
200-
"rpath1",
201-
"rpath2",
202-
]);
203-
}
204-
205-
#[test]
206-
fn test_minimize2() {
207-
let res = minimize_rpaths(&[
208-
"1a".to_string(),
209-
"2".to_string(),
210-
"2".to_string(),
211-
"1a".to_string(),
212-
"4a".to_string(),
213-
"1a".to_string(),
214-
"2".to_string(),
215-
"3".to_string(),
216-
"4a".to_string(),
217-
"3".to_string()
218-
]);
219-
assert!(res == [
220-
"1a",
221-
"2",
222-
"4a",
223-
"3",
224-
]);
225-
}
226-
227-
#[test]
228-
fn test_rpath_relative() {
229-
if cfg!(target_os = "macos") {
230-
let config = &mut RPathConfig {
231-
used_crates: Vec::new(),
232-
has_rpath: true,
233-
is_like_osx: true,
234-
linker_is_gnu: false,
235-
out_filename: PathBuf::from("bin/rustc"),
236-
get_install_prefix_lib_path: &mut || panic!(),
237-
};
238-
let res = get_rpath_relative_to_output(config,
239-
Path::new("lib/libstd.so"));
240-
assert_eq!(res, "@loader_path/../lib");
241-
} else {
242-
let config = &mut RPathConfig {
243-
used_crates: Vec::new(),
244-
out_filename: PathBuf::from("bin/rustc"),
245-
get_install_prefix_lib_path: &mut || panic!(),
246-
has_rpath: true,
247-
is_like_osx: false,
248-
linker_is_gnu: true,
249-
};
250-
let res = get_rpath_relative_to_output(config,
251-
Path::new("lib/libstd.so"));
252-
assert_eq!(res, "$ORIGIN/../lib");
253-
}
254-
}
255-
256-
#[test]
257-
fn test_xlinker() {
258-
let args = rpaths_to_flags(&[
259-
"a/normal/path".to_string(),
260-
"a,comma,path".to_string()
261-
]);
262-
263-
assert_eq!(args, vec![
264-
"-Wl,-rpath,a/normal/path".to_string(),
265-
"-Wl,-rpath".to_string(),
266-
"-Xlinker".to_string(),
267-
"a,comma,path".to_string()
268-
]);
269-
}
270-
}
176+
mod tests;
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
use super::{RPathConfig};
2+
use super::{minimize_rpaths, rpaths_to_flags, get_rpath_relative_to_output};
3+
use std::path::{Path, PathBuf};
4+
5+
#[test]
6+
fn test_rpaths_to_flags() {
7+
let flags = rpaths_to_flags(&[
8+
"path1".to_string(),
9+
"path2".to_string()
10+
]);
11+
assert_eq!(flags,
12+
["-Wl,-rpath,path1",
13+
"-Wl,-rpath,path2"]);
14+
}
15+
16+
#[test]
17+
fn test_minimize1() {
18+
let res = minimize_rpaths(&[
19+
"rpath1".to_string(),
20+
"rpath2".to_string(),
21+
"rpath1".to_string()
22+
]);
23+
assert!(res == [
24+
"rpath1",
25+
"rpath2",
26+
]);
27+
}
28+
29+
#[test]
30+
fn test_minimize2() {
31+
let res = minimize_rpaths(&[
32+
"1a".to_string(),
33+
"2".to_string(),
34+
"2".to_string(),
35+
"1a".to_string(),
36+
"4a".to_string(),
37+
"1a".to_string(),
38+
"2".to_string(),
39+
"3".to_string(),
40+
"4a".to_string(),
41+
"3".to_string()
42+
]);
43+
assert!(res == [
44+
"1a",
45+
"2",
46+
"4a",
47+
"3",
48+
]);
49+
}
50+
51+
#[test]
52+
fn test_rpath_relative() {
53+
if cfg!(target_os = "macos") {
54+
let config = &mut RPathConfig {
55+
used_crates: Vec::new(),
56+
has_rpath: true,
57+
is_like_osx: true,
58+
linker_is_gnu: false,
59+
out_filename: PathBuf::from("bin/rustc"),
60+
get_install_prefix_lib_path: &mut || panic!(),
61+
};
62+
let res = get_rpath_relative_to_output(config,
63+
Path::new("lib/libstd.so"));
64+
assert_eq!(res, "@loader_path/../lib");
65+
} else {
66+
let config = &mut RPathConfig {
67+
used_crates: Vec::new(),
68+
out_filename: PathBuf::from("bin/rustc"),
69+
get_install_prefix_lib_path: &mut || panic!(),
70+
has_rpath: true,
71+
is_like_osx: false,
72+
linker_is_gnu: true,
73+
};
74+
let res = get_rpath_relative_to_output(config,
75+
Path::new("lib/libstd.so"));
76+
assert_eq!(res, "$ORIGIN/../lib");
77+
}
78+
}
79+
80+
#[test]
81+
fn test_xlinker() {
82+
let args = rpaths_to_flags(&[
83+
"a/normal/path".to_string(),
84+
"a,comma,path".to_string()
85+
]);
86+
87+
assert_eq!(args, vec![
88+
"-Wl,-rpath,a/normal/path".to_string(),
89+
"-Wl,-rpath".to_string(),
90+
"-Xlinker".to_string(),
91+
"a,comma,path".to_string()
92+
]);
93+
}

0 commit comments

Comments
 (0)