Pass themes folder as parameter

This commit is contained in:
Guillaume Gomez
2018-01-27 22:12:28 +01:00
parent 51580d46f9
commit b1b11d4589
4 changed files with 14 additions and 12 deletions

View File

@@ -451,7 +451,9 @@ impl Step for RustdocTheme {
fn run(self, builder: &Builder) { fn run(self, builder: &Builder) {
let rustdoc = builder.rustdoc(self.compiler.host); let rustdoc = builder.rustdoc(self.compiler.host);
let mut cmd = Command::new(builder.config.python.clone().expect("python not defined")); let mut cmd = Command::new(builder.config.python.clone().expect("python not defined"));
cmd.args(&["src/tools/rustdoc-themes/test-themes.py", rustdoc.to_str().unwrap()]); cmd.args(&[builder.src.join("src/tools/rustdoc-themes/test-themes.py").to_str().unwrap(),
rustdoc.to_str().unwrap(),
builder.src.join("src/librustdoc/html/static/themes").to_str().unwrap()]);
cmd.env("RUSTC_STAGE", self.compiler.stage.to_string()) cmd.env("RUSTC_STAGE", self.compiler.stage.to_string())
.env("RUSTC_SYSROOT", builder.sysroot(self.compiler)) .env("RUSTC_SYSROOT", builder.sysroot(self.compiler))
.env("RUSTDOC_LIBDIR", builder.sysroot_libdir(self.compiler, self.compiler.host)) .env("RUSTDOC_LIBDIR", builder.sysroot_libdir(self.compiler, self.compiler.host))

View File

@@ -332,10 +332,10 @@ pub fn main_args(args: &[String]) -> isize {
print!(" - Checking \"{}\"...", theme_file); print!(" - Checking \"{}\"...", theme_file);
let (success, differences) = theme::test_theme_against(theme_file, &paths); let (success, differences) = theme::test_theme_against(theme_file, &paths);
if !differences.is_empty() || !success { if !differences.is_empty() || !success {
eprintln!(" FAILED"); println!(" FAILED");
errors += 1; errors += 1;
if !differences.is_empty() { if !differences.is_empty() {
eprintln!("{}", differences.join("\n")); println!("{}", differences.join("\n"));
} }
} else { } else {
println!(" OK"); println!(" OK");
@@ -407,13 +407,13 @@ pub fn main_args(args: &[String]) -> isize {
.iter() .iter()
.map(|s| (PathBuf::from(&s), s.to_owned())) { .map(|s| (PathBuf::from(&s), s.to_owned())) {
if !theme_file.is_file() { if !theme_file.is_file() {
eprintln!("rustdoc: option --themes arguments must all be files"); println!("rustdoc: option --themes arguments must all be files");
return 1; return 1;
} }
let (success, ret) = theme::test_theme_against(&theme_file, &paths); let (success, ret) = theme::test_theme_against(&theme_file, &paths);
if !success || !ret.is_empty() { if !success || !ret.is_empty() {
eprintln!("rustdoc: invalid theme: \"{}\"", theme_s); println!("rustdoc: invalid theme: \"{}\"", theme_s);
eprintln!(" Check what's wrong with the \"theme-checker\" option"); println!(" Check what's wrong with the \"theme-checker\" option");
return 1; return 1;
} }
themes.push(theme_file); themes.push(theme_file);

View File

@@ -348,7 +348,7 @@ c // sdf
d {} d {}
"#; "#;
let paths = load_css_paths(text.as_bytes()); let paths = load_css_paths(text.as_bytes());
assert!(paths.children.get(&CssPath::new("a b c d".to_owned())).is_some()); assert!(paths.children.contains(&CssPath::new("a b c d".to_owned())));
} }
#[test] #[test]

View File

@@ -17,7 +17,6 @@ import subprocess
import sys import sys
FILES_TO_IGNORE = ['main.css'] FILES_TO_IGNORE = ['main.css']
THEME_DIR_PATH = "src/librustdoc/html/static/themes"
def print_err(msg): def print_err(msg):
@@ -31,14 +30,15 @@ def exec_command(command):
def main(argv): def main(argv):
if len(argv) < 1: if len(argv) < 2:
print_err("Needs rustdoc binary path") print_err("Needs rustdoc binary path")
return 1 return 1
rustdoc_bin = argv[0] rustdoc_bin = argv[0]
themes = [join(THEME_DIR_PATH, f) for f in listdir(THEME_DIR_PATH) themes_folder = argv[1]
if isfile(join(THEME_DIR_PATH, f)) and f not in FILES_TO_IGNORE] themes = [join(themes_folder, f) for f in listdir(themes_folder)
if isfile(join(themes_folder, f)) and f not in FILES_TO_IGNORE]
if len(themes) < 1: if len(themes) < 1:
print_err('No theme found in "{}"...'.format(THEME_DIR_PATH)) print_err('No theme found in "{}"...'.format(themes_folder))
return 1 return 1
args = [rustdoc_bin, '-Z', 'unstable-options', '--theme-checker'] args = [rustdoc_bin, '-Z', 'unstable-options', '--theme-checker']
args.extend(themes) args.extend(themes)