3 # Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
4 # file at the top-level directory of this distribution and at
5 # http://rust-lang.org/COPYRIGHT.
7 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
8 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
9 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
10 # option. This file may not be copied, modified, or distributed
11 # except according to those terms.
20 def error_unless_permitted(env_var, message):
22 if not os.getenv(env_var):
23 sys.stderr.write(message)
26 def only_on(platforms):
28 @functools.wraps(func)
30 if any(map(lambda x: sys.platform.startswith(x), platforms)):
35 @only_on(['linux', 'darwin', 'freebsd', 'openbsd'])
36 def check_rlimit_core():
38 soft, hard = resource.getrlimit(resource.RLIMIT_CORE)
40 error_unless_permitted('ALLOW_NONZERO_RLIMIT_CORE', """\
41 RLIMIT_CORE is set to a nonzero value (%d). During debuginfo, the test suite
42 will segfault many rustc's, creating many potentially large core files.
43 set ALLOW_NONZERO_RLIMIT_CORE to ignore this warning
47 def check_console_code_page():
48 if '65001' not in subprocess.check_output(['cmd', '/c', 'chcp']):
49 sys.stderr.write('Warning: the console output code page is not UTF-8, \
50 some tests may fail. Use `cmd /c "chcp 65001"` to setup UTF-8 code page.\n')
53 check_console_code_page()
56 if __name__ == '__main__':