diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2018-01-26 00:44:52 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2018-02-08 10:53:09 +0100 |
| commit | 51580d46f919c1f97d82aeca1ea1086c545c7484 (patch) | |
| tree | 9c14eccb3366b76e988077a9d12bc1724c612a47 /src/tools | |
| parent | 63ee1cd846b92eb3a124ec345d4889bdb5bca8e3 (diff) | |
| download | rust-51580d46f919c1f97d82aeca1ea1086c545c7484.tar.gz rust-51580d46f919c1f97d82aeca1ea1086c545c7484.zip | |
Add tests for themes
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/rustdoc-themes/test-themes.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/tools/rustdoc-themes/test-themes.py b/src/tools/rustdoc-themes/test-themes.py new file mode 100644 index 00000000000..27756e3bef6 --- /dev/null +++ b/src/tools/rustdoc-themes/test-themes.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Copyright 2018 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +from os import listdir +from os.path import isfile, join +import subprocess +import sys + +FILES_TO_IGNORE = ['main.css'] +THEME_DIR_PATH = "src/librustdoc/html/static/themes" + + +def print_err(msg): + sys.stderr.write('{}\n'.format(msg)) + + +def exec_command(command): + child = subprocess.Popen(command) + stdout, stderr = child.communicate() + return child.returncode + + +def main(argv): + if len(argv) < 1: + print_err("Needs rustdoc binary path") + return 1 + rustdoc_bin = argv[0] + themes = [join(THEME_DIR_PATH, f) for f in listdir(THEME_DIR_PATH) + if isfile(join(THEME_DIR_PATH, f)) and f not in FILES_TO_IGNORE] + if len(themes) < 1: + print_err('No theme found in "{}"...'.format(THEME_DIR_PATH)) + return 1 + args = [rustdoc_bin, '-Z', 'unstable-options', '--theme-checker'] + args.extend(themes) + return exec_command(args) + + +if __name__ != '__main__': + print_err("Needs to be run as main") + sys.exit(1) +else: + sys.exit(main(sys.argv[1:])) |
