1
Fork 0

librustdoc: De-export compiletest, combine-tests, libcargo, libfuzzer, and librustdoc. rs=deexporting

This commit is contained in:
Patrick Walton 2013-01-30 14:10:03 -08:00
parent d73bf62952
commit 83ced67d0b
19 changed files with 213 additions and 256 deletions

View file

@ -12,16 +12,15 @@ use core::prelude::*;
use cmp; use cmp;
enum mode { mode_compile_fail, mode_run_fail, mode_run_pass, mode_pretty, } #[deriving_eq]
pub enum mode {
impl mode : cmp::Eq { mode_compile_fail,
pure fn eq(&self, other: &mode) -> bool { mode_run_fail,
(*other) as int == (*self) as int mode_run_pass,
} mode_pretty,
pure fn ne(&self, other: &mode) -> bool { !(*self).eq(other) }
} }
type config = { pub type config = {
// The library paths required for running the compiler // The library paths required for running the compiler
compile_lib_path: ~str, compile_lib_path: ~str,

View file

@ -11,7 +11,6 @@
#[crate_type = "bin"]; #[crate_type = "bin"];
#[no_core]; #[no_core];
#[legacy_exports];
#[legacy_records]; #[legacy_records];
#[allow(vecs_implicitly_copyable)]; #[allow(vecs_implicitly_copyable)];
@ -24,17 +23,11 @@ extern mod std(vers = "0.6");
use core::*; use core::*;
#[legacy_exports]
mod procsrv; mod procsrv;
#[legacy_exports]
mod util; mod util;
#[legacy_exports]
mod header; mod header;
#[legacy_exports]
mod runtest; mod runtest;
#[legacy_exports]
mod common; mod common;
#[legacy_exports]
mod errors; mod errors;
use std::getopts; use std::getopts;
@ -51,14 +44,14 @@ use common::mode_pretty;
use common::mode; use common::mode;
use util::logv; use util::logv;
fn main() { pub fn main() {
let args = os::args(); let args = os::args();
let config = parse_config(args); let config = parse_config(args);
log_config(config); log_config(config);
run_tests(config); run_tests(config);
} }
fn parse_config(args: ~[~str]) -> config { pub fn parse_config(args: ~[~str]) -> config {
let opts = let opts =
~[getopts::reqopt(~"compile-lib-path"), ~[getopts::reqopt(~"compile-lib-path"),
getopts::reqopt(~"run-lib-path"), getopts::reqopt(~"run-lib-path"),
@ -105,7 +98,7 @@ fn parse_config(args: ~[~str]) -> config {
verbose: getopts::opt_present(matches, ~"verbose")}; verbose: getopts::opt_present(matches, ~"verbose")};
} }
fn log_config(config: config) { pub fn log_config(config: config) {
let c = config; let c = config;
logv(c, fmt!("configuration:")); logv(c, fmt!("configuration:"));
logv(c, fmt!("compile_lib_path: %s", config.compile_lib_path)); logv(c, fmt!("compile_lib_path: %s", config.compile_lib_path));
@ -124,15 +117,15 @@ fn log_config(config: config) {
logv(c, fmt!("\n")); logv(c, fmt!("\n"));
} }
fn opt_str(maybestr: Option<~str>) -> ~str { pub fn opt_str(maybestr: Option<~str>) -> ~str {
match maybestr { option::Some(s) => s, option::None => ~"(none)" } match maybestr { option::Some(s) => s, option::None => ~"(none)" }
} }
fn str_opt(maybestr: ~str) -> Option<~str> { pub fn str_opt(maybestr: ~str) -> Option<~str> {
if maybestr != ~"(none)" { option::Some(maybestr) } else { option::None } if maybestr != ~"(none)" { option::Some(maybestr) } else { option::None }
} }
fn str_mode(s: ~str) -> mode { pub fn str_mode(s: ~str) -> mode {
match s { match s {
~"compile-fail" => mode_compile_fail, ~"compile-fail" => mode_compile_fail,
~"run-fail" => mode_run_fail, ~"run-fail" => mode_run_fail,
@ -142,7 +135,7 @@ fn str_mode(s: ~str) -> mode {
} }
} }
fn mode_str(mode: mode) -> ~str { pub fn mode_str(mode: mode) -> ~str {
match mode { match mode {
mode_compile_fail => ~"compile-fail", mode_compile_fail => ~"compile-fail",
mode_run_fail => ~"run-fail", mode_run_fail => ~"run-fail",
@ -151,14 +144,14 @@ fn mode_str(mode: mode) -> ~str {
} }
} }
fn run_tests(config: config) { pub fn run_tests(config: config) {
let opts = test_opts(config); let opts = test_opts(config);
let tests = make_tests(config); let tests = make_tests(config);
let res = test::run_tests_console(&opts, tests); let res = test::run_tests_console(&opts, tests);
if !res { fail ~"Some tests failed"; } if !res { fail ~"Some tests failed"; }
} }
fn test_opts(config: config) -> test::TestOpts { pub fn test_opts(config: config) -> test::TestOpts {
test::TestOpts { test::TestOpts {
filter: config.filter, filter: config.filter,
run_ignored: config.run_ignored, run_ignored: config.run_ignored,
@ -166,7 +159,7 @@ fn test_opts(config: config) -> test::TestOpts {
} }
} }
fn make_tests(config: config) -> ~[test::TestDesc] { pub fn make_tests(config: config) -> ~[test::TestDesc] {
debug!("making tests from %s", debug!("making tests from %s",
config.src_base.to_str()); config.src_base.to_str());
let mut tests = ~[]; let mut tests = ~[];
@ -180,7 +173,7 @@ fn make_tests(config: config) -> ~[test::TestDesc] {
move tests move tests
} }
fn is_test(config: config, testfile: &Path) -> bool { pub fn is_test(config: config, testfile: &Path) -> bool {
// Pretty-printer does not work with .rc files yet // Pretty-printer does not work with .rc files yet
let valid_extensions = let valid_extensions =
match config.mode { match config.mode {
@ -203,7 +196,7 @@ fn is_test(config: config, testfile: &Path) -> bool {
return valid; return valid;
} }
fn make_test(config: config, testfile: &Path) -> pub fn make_test(config: config, testfile: &Path) ->
test::TestDesc { test::TestDesc {
test::TestDesc { test::TestDesc {
name: make_test_name(config, testfile), name: make_test_name(config, testfile),
@ -213,11 +206,11 @@ fn make_test(config: config, testfile: &Path) ->
} }
} }
fn make_test_name(config: config, testfile: &Path) -> ~str { pub fn make_test_name(config: config, testfile: &Path) -> ~str {
fmt!("[%s] %s", mode_str(config.mode), testfile.to_str()) fmt!("[%s] %s", mode_str(config.mode), testfile.to_str())
} }
fn make_test_closure(config: config, testfile: &Path) -> test::TestFn { pub fn make_test_closure(config: config, testfile: &Path) -> test::TestFn {
let testfile = testfile.to_str(); let testfile = testfile.to_str();
fn~() { runtest::run(config, testfile) } fn~() { runtest::run(config, testfile) }
} }

View file

@ -15,13 +15,10 @@ use io;
use io::ReaderUtil; use io::ReaderUtil;
use str; use str;
export load_errors; pub struct ExpectedError { line: uint, kind: ~str, msg: ~str }
export ExpectedError;
struct ExpectedError { line: uint, kind: ~str, msg: ~str }
// Load any test directives embedded in the file // Load any test directives embedded in the file
fn load_errors(testfile: &Path) -> ~[ExpectedError] { pub fn load_errors(testfile: &Path) -> ~[ExpectedError] {
let mut error_patterns = ~[]; let mut error_patterns = ~[];
let rdr = io::file_reader(testfile).get(); let rdr = io::file_reader(testfile).get();
let mut line_num = 1u; let mut line_num = 1u;

View file

@ -17,11 +17,7 @@ use io::ReaderUtil;
use os; use os;
use str; use str;
export TestProps; pub struct TestProps {
export load_props;
export is_test_ignored;
struct TestProps {
// Lines that should be expected, in order, on standard out // Lines that should be expected, in order, on standard out
error_patterns: ~[~str], error_patterns: ~[~str],
// Extra flags to pass to the compiler // Extra flags to pass to the compiler
@ -36,7 +32,7 @@ struct TestProps {
} }
// Load any test directives embedded in the file // Load any test directives embedded in the file
fn load_props(testfile: &Path) -> TestProps { pub fn load_props(testfile: &Path) -> TestProps {
let mut error_patterns = ~[]; let mut error_patterns = ~[];
let mut aux_builds = ~[]; let mut aux_builds = ~[];
let mut exec_env = ~[]; let mut exec_env = ~[];
@ -73,7 +69,7 @@ fn load_props(testfile: &Path) -> TestProps {
}; };
} }
fn is_test_ignored(config: config, testfile: &Path) -> bool { pub fn is_test_ignored(config: config, testfile: &Path) -> bool {
let mut found = false; let mut found = false;
for iter_header(testfile) |ln| { for iter_header(testfile) |ln| {
if parse_name_directive(ln, ~"xfail-test") { return true; } if parse_name_directive(ln, ~"xfail-test") { return true; }

View file

@ -22,8 +22,6 @@ use str;
use task; use task;
use vec; use vec;
export run;
#[cfg(target_os = "win32")] #[cfg(target_os = "win32")]
fn target_env(lib_path: ~str, prog: ~str) -> ~[(~str,~str)] { fn target_env(lib_path: ~str, prog: ~str) -> ~[(~str,~str)] {
@ -54,12 +52,11 @@ fn target_env(_lib_path: ~str, _prog: ~str) -> ~[(~str,~str)] {
struct Result {status: int, out: ~str, err: ~str} struct Result {status: int, out: ~str, err: ~str}
// FIXME (#2659): This code is duplicated in core::run::program_output // FIXME (#2659): This code is duplicated in core::run::program_output
fn run(lib_path: ~str, pub fn run(lib_path: ~str,
prog: ~str, prog: ~str,
args: ~[~str], args: ~[~str],
env: ~[(~str, ~str)], env: ~[(~str, ~str)],
input: Option<~str>) -> Result { input: Option<~str>) -> Result {
let pipe_in = os::pipe(); let pipe_in = os::pipe();
let pipe_out = os::pipe(); let pipe_out = os::pipe();
let pipe_err = os::pipe(); let pipe_err = os::pipe();

View file

@ -31,9 +31,7 @@ use procsrv;
use util; use util;
use util::logv; use util::logv;
export run; pub fn run(config: config, testfile: ~str) {
fn run(config: config, testfile: ~str) {
if config.verbose { if config.verbose {
// We're going to be dumping a lot of info. Start on a new line. // We're going to be dumping a lot of info. Start on a new line.
io::stdout().write_str(~"\n\n"); io::stdout().write_str(~"\n\n");

View file

@ -17,7 +17,7 @@ use os::getenv;
use common; use common;
use common::config; use common::config;
fn make_new_path(path: ~str) -> ~str { pub fn make_new_path(path: ~str) -> ~str {
// Windows just uses PATH as the library search path, so we have to // Windows just uses PATH as the library search path, so we have to
// maintain the current value while adding our own // maintain the current value while adding our own
@ -31,23 +31,23 @@ fn make_new_path(path: ~str) -> ~str {
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
#[cfg(target_os = "freebsd")] #[cfg(target_os = "freebsd")]
fn lib_path_env_var() -> ~str { ~"LD_LIBRARY_PATH" } pub fn lib_path_env_var() -> ~str { ~"LD_LIBRARY_PATH" }
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
fn lib_path_env_var() -> ~str { ~"DYLD_LIBRARY_PATH" } pub fn lib_path_env_var() -> ~str { ~"DYLD_LIBRARY_PATH" }
#[cfg(target_os = "win32")] #[cfg(target_os = "win32")]
fn lib_path_env_var() -> ~str { ~"PATH" } pub fn lib_path_env_var() -> ~str { ~"PATH" }
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
#[cfg(target_os = "freebsd")] #[cfg(target_os = "freebsd")]
fn path_div() -> ~str { ~":" } pub fn path_div() -> ~str { ~":" }
#[cfg(target_os = "win32")] #[cfg(target_os = "win32")]
fn path_div() -> ~str { ~";" } pub fn path_div() -> ~str { ~";" }
fn logv(config: config, s: ~str) { pub fn logv(config: config, s: ~str) {
log(debug, s); log(debug, s);
if config.verbose { io::println(s); } if config.verbose { io::println(s); }
} }

View file

@ -37,14 +37,12 @@ stage2_tests.sort()
c = open("tmp/run_pass_stage2.rc", "w") c = open("tmp/run_pass_stage2.rc", "w")
i = 0 i = 0
c.write("// AUTO-GENERATED FILE: DO NOT EDIT\n") c.write("// AUTO-GENERATED FILE: DO NOT EDIT\n")
c.write("#[legacy_exports];\n")
c.write("#[link(name=\"run_pass_stage2\", vers=\"0.1\")];\n") c.write("#[link(name=\"run_pass_stage2\", vers=\"0.1\")];\n")
for t in stage2_tests: for t in stage2_tests:
p = os.path.join(run_pass, t) p = os.path.join(run_pass, t)
p = p.replace("\\", "\\\\") p = p.replace("\\", "\\\\")
c.write("#[path = \"%s\"]" % p); c.write("#[path = \"%s\"]" % p);
c.write("#[legacy_exports]"); c.write("pub mod t_%d;\n" % i)
c.write("mod t_%d;\n" % i)
i += 1 i += 1
c.close() c.close()

View file

@ -26,7 +26,6 @@
#[crate_type = "lib"]; #[crate_type = "lib"];
#[no_core]; #[no_core];
#[legacy_exports];
#[legacy_modes]; #[legacy_modes];
@ -42,7 +41,6 @@ extern mod std(vers = "0.6");
extern mod rustc(vers = "0.6"); extern mod rustc(vers = "0.6");
extern mod syntax(vers = "0.6"); extern mod syntax(vers = "0.6");
#[legacy_exports]
mod pgp; mod pgp;
use rustc::metadata::filesearch::{get_cargo_root, get_cargo_root_nearest}; use rustc::metadata::filesearch::{get_cargo_root, get_cargo_root_nearest};
@ -62,7 +60,7 @@ use syntax::diagnostic::span_handler;
use syntax::diagnostic; use syntax::diagnostic;
use syntax::{ast, codemap, parse, visit, attr}; use syntax::{ast, codemap, parse, visit, attr};
struct Package { pub struct Package {
name: ~str, name: ~str,
uuid: ~str, uuid: ~str,
url: ~str, url: ~str,
@ -73,7 +71,7 @@ struct Package {
versions: ~[(~str, ~str)] versions: ~[(~str, ~str)]
} }
impl Package : cmp::Ord { pub impl Package : cmp::Ord {
pure fn lt(&self, other: &Package) -> bool { pure fn lt(&self, other: &Package) -> bool {
if (*self).name.lt(&(*other).name) { return true; } if (*self).name.lt(&(*other).name) { return true; }
if (*other).name.lt(&(*self).name) { return false; } if (*other).name.lt(&(*self).name) { return false; }
@ -95,7 +93,7 @@ impl Package : cmp::Ord {
pure fn gt(&self, other: &Package) -> bool { (*other).lt(&(*self)) } pure fn gt(&self, other: &Package) -> bool { (*other).lt(&(*self)) }
} }
struct Source { pub struct Source {
name: ~str, name: ~str,
mut url: ~str, mut url: ~str,
mut method: ~str, mut method: ~str,
@ -104,7 +102,7 @@ struct Source {
packages: DVec<Package> packages: DVec<Package>
} }
struct Cargo { pub struct Cargo {
pgp: bool, pgp: bool,
root: Path, root: Path,
installdir: Path, installdir: Path,
@ -118,7 +116,7 @@ struct Cargo {
opts: Options opts: Options
} }
struct Crate { pub struct Crate {
name: ~str, name: ~str,
vers: ~str, vers: ~str,
uuid: ~str, uuid: ~str,
@ -128,28 +126,22 @@ struct Crate {
deps: ~[~str] deps: ~[~str]
} }
struct Options { pub struct Options {
test: bool, test: bool,
mode: Mode, mode: Mode,
free: ~[~str], free: ~[~str],
help: bool, help: bool,
} }
enum Mode { SystemMode, UserMode, LocalMode } #[deriving_eq]
pub enum Mode { SystemMode, UserMode, LocalMode }
impl Mode : cmp::Eq { pub fn opts() -> ~[getopts::Opt] {
pure fn eq(&self, other: &Mode) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(&self, other: &Mode) -> bool { !(*self).eq(other) }
}
fn opts() -> ~[getopts::Opt] {
~[optflag(~"g"), optflag(~"G"), optflag(~"test"), ~[optflag(~"g"), optflag(~"G"), optflag(~"test"),
optflag(~"h"), optflag(~"help")] optflag(~"h"), optflag(~"help")]
} }
fn info(msg: ~str) { pub fn info(msg: ~str) {
let out = io::stdout(); let out = io::stdout();
if term::color_supported() { if term::color_supported() {
@ -160,7 +152,7 @@ fn info(msg: ~str) {
} else { out.write_line(~"info: " + msg); } } else { out.write_line(~"info: " + msg); }
} }
fn warn(msg: ~str) { pub fn warn(msg: ~str) {
let out = io::stdout(); let out = io::stdout();
if term::color_supported() { if term::color_supported() {
@ -171,7 +163,7 @@ fn warn(msg: ~str) {
}else { out.write_line(~"warning: " + msg); } }else { out.write_line(~"warning: " + msg); }
} }
fn error(msg: ~str) { pub fn error(msg: ~str) {
let out = io::stdout(); let out = io::stdout();
if term::color_supported() { if term::color_supported() {
@ -183,7 +175,7 @@ fn error(msg: ~str) {
else { out.write_line(~"error: " + msg); } else { out.write_line(~"error: " + msg); }
} }
fn is_uuid(id: ~str) -> bool { pub fn is_uuid(id: ~str) -> bool {
let parts = str::split_str(id, ~"-"); let parts = str::split_str(id, ~"-");
if vec::len(parts) == 5u { if vec::len(parts) == 5u {
let mut correct = 0u; let mut correct = 0u;
@ -225,7 +217,7 @@ fn is_uuid(id: ~str) -> bool {
} }
#[test] #[test]
fn test_is_uuid() { pub fn test_is_uuid() {
assert is_uuid(~"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaafAF09"); assert is_uuid(~"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaafAF09");
assert !is_uuid(~"aaaaaaaa-aaaa-aaaa-aaaaa-aaaaaaaaaaaa"); assert !is_uuid(~"aaaaaaaa-aaaa-aaaa-aaaaa-aaaaaaaaaaaa");
assert !is_uuid(~""); assert !is_uuid(~"");
@ -238,7 +230,7 @@ fn test_is_uuid() {
// FIXME (#2661): implement url/URL parsing so we don't have to resort // FIXME (#2661): implement url/URL parsing so we don't have to resort
// to weak checks // to weak checks
fn has_archive_extension(p: ~str) -> bool { pub fn has_archive_extension(p: ~str) -> bool {
str::ends_with(p, ~".tar") || str::ends_with(p, ~".tar") ||
str::ends_with(p, ~".tar.gz") || str::ends_with(p, ~".tar.gz") ||
str::ends_with(p, ~".tar.bz2") || str::ends_with(p, ~".tar.bz2") ||
@ -254,11 +246,11 @@ fn has_archive_extension(p: ~str) -> bool {
str::ends_with(p, ~".txz") str::ends_with(p, ~".txz")
} }
fn is_archive_path(u: ~str) -> bool { pub fn is_archive_path(u: ~str) -> bool {
has_archive_extension(u) && os::path_exists(&Path(u)) has_archive_extension(u) && os::path_exists(&Path(u))
} }
fn is_archive_url(u: ~str) -> bool { pub fn is_archive_url(u: ~str) -> bool {
// FIXME (#2661): this requires the protocol bit - if we had proper // FIXME (#2661): this requires the protocol bit - if we had proper
// url parsing, we wouldn't need it // url parsing, we wouldn't need it
@ -268,14 +260,14 @@ fn is_archive_url(u: ~str) -> bool {
} }
} }
fn is_git_url(url: ~str) -> bool { pub fn is_git_url(url: ~str) -> bool {
if str::ends_with(url, ~"/") { str::ends_with(url, ~".git/") } if str::ends_with(url, ~"/") { str::ends_with(url, ~".git/") }
else { else {
str::starts_with(url, ~"git://") || str::ends_with(url, ~".git") str::starts_with(url, ~"git://") || str::ends_with(url, ~".git")
} }
} }
fn assume_source_method(url: ~str) -> ~str { pub fn assume_source_method(url: ~str) -> ~str {
if is_git_url(url) { if is_git_url(url) {
return ~"git"; return ~"git";
} }
@ -286,9 +278,9 @@ fn assume_source_method(url: ~str) -> ~str {
~"curl" ~"curl"
} }
fn load_link(mis: ~[@ast::meta_item]) -> (Option<~str>, pub fn load_link(mis: ~[@ast::meta_item]) -> (Option<~str>,
Option<~str>, Option<~str>,
Option<~str>) { Option<~str>) {
let mut name = None; let mut name = None;
let mut vers = None; let mut vers = None;
let mut uuid = None; let mut uuid = None;
@ -309,7 +301,7 @@ fn load_link(mis: ~[@ast::meta_item]) -> (Option<~str>,
(name, vers, uuid) (name, vers, uuid)
} }
fn load_crate(filename: &Path) -> Option<Crate> { pub fn load_crate(filename: &Path) -> Option<Crate> {
let sess = parse::new_parse_sess(None); let sess = parse::new_parse_sess(None);
let c = parse::parse_crate_from_file(filename, ~[], sess); let c = parse::parse_crate_from_file(filename, ~[], sess);
@ -428,11 +420,11 @@ fn load_crate(filename: &Path) -> Option<Crate> {
} }
} }
fn print(s: ~str) { pub fn print(s: ~str) {
io::stdout().write_line(s); io::stdout().write_line(s);
} }
fn rest(s: ~str, start: uint) -> ~str { pub fn rest(s: ~str, start: uint) -> ~str {
if (start >= str::len(s)) { if (start >= str::len(s)) {
~"" ~""
} else { } else {
@ -440,14 +432,14 @@ fn rest(s: ~str, start: uint) -> ~str {
} }
} }
fn need_dir(s: &Path) { pub fn need_dir(s: &Path) {
if os::path_is_dir(s) { return; } if os::path_is_dir(s) { return; }
if !os::make_dir(s, 493_i32 /* oct: 755 */) { if !os::make_dir(s, 493_i32 /* oct: 755 */) {
fail fmt!("can't make_dir %s", s.to_str()); fail fmt!("can't make_dir %s", s.to_str());
} }
} }
fn valid_pkg_name(s: &str) -> bool { pub fn valid_pkg_name(s: &str) -> bool {
fn is_valid_digit(+c: char) -> bool { fn is_valid_digit(+c: char) -> bool {
('0' <= c && c <= '9') || ('0' <= c && c <= '9') ||
('a' <= c && c <= 'z') || ('a' <= c && c <= 'z') ||
@ -459,7 +451,7 @@ fn valid_pkg_name(s: &str) -> bool {
s.all(is_valid_digit) s.all(is_valid_digit)
} }
fn parse_source(name: ~str, j: &json::Json) -> @Source { pub fn parse_source(name: ~str, j: &json::Json) -> @Source {
if !valid_pkg_name(name) { if !valid_pkg_name(name) {
fail fmt!("'%s' is an invalid source name", name); fail fmt!("'%s' is an invalid source name", name);
} }
@ -497,7 +489,8 @@ fn parse_source(name: ~str, j: &json::Json) -> @Source {
}; };
} }
fn try_parse_sources(filename: &Path, sources: map::HashMap<~str, @Source>) { pub fn try_parse_sources(filename: &Path,
sources: map::HashMap<~str, @Source>) {
if !os::path_exists(filename) { return; } if !os::path_exists(filename) { return; }
let c = io::read_whole_file_str(filename); let c = io::read_whole_file_str(filename);
match json::from_str(c.get()) { match json::from_str(c.get()) {
@ -512,7 +505,7 @@ fn try_parse_sources(filename: &Path, sources: map::HashMap<~str, @Source>) {
} }
} }
fn load_one_source_package(src: @Source, p: &json::Object) { pub fn load_one_source_package(src: @Source, p: &json::Object) {
let name = match p.find(&~"name") { let name = match p.find(&~"name") {
Some(&json::String(n)) => { Some(&json::String(n)) => {
if !valid_pkg_name(n) { if !valid_pkg_name(n) {
@ -614,7 +607,7 @@ fn load_one_source_package(src: @Source, p: &json::Object) {
log(debug, ~" loaded package: " + src.name + ~"/" + name); log(debug, ~" loaded package: " + src.name + ~"/" + name);
} }
fn load_source_info(c: &Cargo, src: @Source) { pub fn load_source_info(c: &Cargo, src: @Source) {
let dir = c.sourcedir.push(src.name); let dir = c.sourcedir.push(src.name);
let srcfile = dir.push("source.json"); let srcfile = dir.push("source.json");
if !os::path_exists(&srcfile) { return; } if !os::path_exists(&srcfile) { return; }
@ -635,7 +628,7 @@ fn load_source_info(c: &Cargo, src: @Source) {
} }
}; };
} }
fn load_source_packages(c: &Cargo, src: @Source) { pub fn load_source_packages(c: &Cargo, src: @Source) {
log(debug, ~"loading source: " + src.name); log(debug, ~"loading source: " + src.name);
let dir = c.sourcedir.push(src.name); let dir = c.sourcedir.push(src.name);
let pkgfile = dir.push("packages.json"); let pkgfile = dir.push("packages.json");
@ -665,7 +658,7 @@ fn load_source_packages(c: &Cargo, src: @Source) {
}; };
} }
fn build_cargo_options(argv: ~[~str]) -> Options { pub fn build_cargo_options(argv: ~[~str]) -> Options {
let matches = &match getopts::getopts(argv, opts()) { let matches = &match getopts::getopts(argv, opts()) {
result::Ok(m) => m, result::Ok(m) => m,
result::Err(f) => { result::Err(f) => {
@ -696,7 +689,7 @@ fn build_cargo_options(argv: ~[~str]) -> Options {
Options {test: test, mode: mode, free: matches.free, help: help} Options {test: test, mode: mode, free: matches.free, help: help}
} }
fn configure(opts: Options) -> Cargo { pub fn configure(opts: Options) -> Cargo {
let home = match get_cargo_root() { let home = match get_cargo_root() {
Ok(home) => home, Ok(home) => home,
Err(_err) => get_cargo_sysroot().get() Err(_err) => get_cargo_sysroot().get()
@ -754,7 +747,7 @@ fn configure(opts: Options) -> Cargo {
move c move c
} }
fn for_each_package(c: &Cargo, b: fn(s: @Source, p: &Package)) { pub fn for_each_package(c: &Cargo, b: fn(s: @Source, p: &Package)) {
for c.sources.each_value |v| { for c.sources.each_value |v| {
for v.packages.each |p| { for v.packages.each |p| {
b(v, p); b(v, p);
@ -763,7 +756,7 @@ fn for_each_package(c: &Cargo, b: fn(s: @Source, p: &Package)) {
} }
// Runs all programs in directory <buildpath> // Runs all programs in directory <buildpath>
fn run_programs(buildpath: &Path) { pub fn run_programs(buildpath: &Path) {
let newv = os::list_dir_path(buildpath); let newv = os::list_dir_path(buildpath);
for newv.each |ct| { for newv.each |ct| {
run::run_program(ct.to_str(), ~[]); run::run_program(ct.to_str(), ~[]);
@ -772,8 +765,8 @@ fn run_programs(buildpath: &Path) {
// Runs rustc in <path + subdir> with the given flags // Runs rustc in <path + subdir> with the given flags
// and returns <patho + subdir> // and returns <patho + subdir>
fn run_in_buildpath(what: &str, path: &Path, subdir: &Path, cf: &Path, pub fn run_in_buildpath(what: &str, path: &Path, subdir: &Path, cf: &Path,
extra_flags: ~[~str]) -> Option<Path> { extra_flags: ~[~str]) -> Option<Path> {
let buildpath = path.push_rel(subdir); let buildpath = path.push_rel(subdir);
need_dir(&buildpath); need_dir(&buildpath);
debug!("%s: %s -> %s", what, cf.to_str(), buildpath.to_str()); debug!("%s: %s -> %s", what, cf.to_str(), buildpath.to_str());
@ -788,7 +781,7 @@ fn run_in_buildpath(what: &str, path: &Path, subdir: &Path, cf: &Path,
Some(buildpath) Some(buildpath)
} }
fn test_one_crate(_c: &Cargo, path: &Path, cf: &Path) { pub fn test_one_crate(_c: &Cargo, path: &Path, cf: &Path) {
let buildpath = match run_in_buildpath(~"testing", path, let buildpath = match run_in_buildpath(~"testing", path,
&Path("test"), &Path("test"),
cf, cf,
@ -799,7 +792,7 @@ fn test_one_crate(_c: &Cargo, path: &Path, cf: &Path) {
run_programs(&buildpath); run_programs(&buildpath);
} }
fn install_one_crate(c: &Cargo, path: &Path, cf: &Path) { pub fn install_one_crate(c: &Cargo, path: &Path, cf: &Path) {
let buildpath = match run_in_buildpath(~"installing", path, let buildpath = match run_in_buildpath(~"installing", path,
&Path("build"), &Path("build"),
cf, ~[]) { cf, ~[]) {
@ -829,7 +822,7 @@ fn install_one_crate(c: &Cargo, path: &Path, cf: &Path) {
} }
fn rustc_sysroot() -> ~str { pub fn rustc_sysroot() -> ~str {
match os::self_exe_path() { match os::self_exe_path() {
Some(path) => { Some(path) => {
let rustc = path.push_many([~"..", ~"bin", ~"rustc"]); let rustc = path.push_many([~"..", ~"bin", ~"rustc"]);
@ -840,7 +833,7 @@ fn rustc_sysroot() -> ~str {
} }
} }
fn install_source(c: &Cargo, path: &Path) { pub fn install_source(c: &Cargo, path: &Path) {
debug!("source: %s", path.to_str()); debug!("source: %s", path.to_str());
os::change_dir(path); os::change_dir(path);
@ -879,7 +872,7 @@ fn install_source(c: &Cargo, path: &Path) {
} }
} }
fn install_git(c: &Cargo, wd: &Path, url: ~str, reference: Option<~str>) { pub fn install_git(c: &Cargo, wd: &Path, url: ~str, reference: Option<~str>) {
run::program_output(~"git", ~[~"clone", url, wd.to_str()]); run::program_output(~"git", ~[~"clone", url, wd.to_str()]);
if reference.is_some() { if reference.is_some() {
let r = reference.get(); let r = reference.get();
@ -890,7 +883,7 @@ fn install_git(c: &Cargo, wd: &Path, url: ~str, reference: Option<~str>) {
install_source(c, wd); install_source(c, wd);
} }
fn install_curl(c: &Cargo, wd: &Path, url: ~str) { pub fn install_curl(c: &Cargo, wd: &Path, url: ~str) {
let tarpath = wd.push("pkg.tar"); let tarpath = wd.push("pkg.tar");
let p = run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o", let p = run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o",
tarpath.to_str(), url]); tarpath.to_str(), url]);
@ -903,14 +896,14 @@ fn install_curl(c: &Cargo, wd: &Path, url: ~str) {
install_source(c, wd); install_source(c, wd);
} }
fn install_file(c: &Cargo, wd: &Path, path: &Path) { pub fn install_file(c: &Cargo, wd: &Path, path: &Path) {
run::program_output(~"tar", ~[~"-x", ~"--strip-components=1", run::program_output(~"tar", ~[~"-x", ~"--strip-components=1",
~"-C", wd.to_str(), ~"-C", wd.to_str(),
~"-f", path.to_str()]); ~"-f", path.to_str()]);
install_source(c, wd); install_source(c, wd);
} }
fn install_package(c: &Cargo, src: ~str, wd: &Path, pkg: Package) { pub fn install_package(c: &Cargo, src: ~str, wd: &Path, pkg: Package) {
let url = copy pkg.url; let url = copy pkg.url;
let method = match pkg.method { let method = match pkg.method {
~"git" => ~"git", ~"git" => ~"git",
@ -928,8 +921,7 @@ fn install_package(c: &Cargo, src: ~str, wd: &Path, pkg: Package) {
} }
} }
fn cargo_suggestion(c: &Cargo, fallback: fn()) pub fn cargo_suggestion(c: &Cargo, fallback: fn()) {
{
if c.sources.size() == 0u { if c.sources.size() == 0u {
error(~"no sources defined - you may wish to run " + error(~"no sources defined - you may wish to run " +
~"`cargo init`"); ~"`cargo init`");
@ -938,7 +930,7 @@ fn cargo_suggestion(c: &Cargo, fallback: fn())
fallback(); fallback();
} }
fn install_uuid(c: &Cargo, wd: &Path, uuid: ~str) { pub fn install_uuid(c: &Cargo, wd: &Path, uuid: ~str) {
let mut ps = ~[]; let mut ps = ~[];
for_each_package(c, |s, p| { for_each_package(c, |s, p| {
if p.uuid == uuid { if p.uuid == uuid {
@ -962,7 +954,7 @@ fn install_uuid(c: &Cargo, wd: &Path, uuid: ~str) {
} }
} }
fn install_named(c: &Cargo, wd: &Path, name: ~str) { pub fn install_named(c: &Cargo, wd: &Path, name: ~str) {
let mut ps = ~[]; let mut ps = ~[];
for_each_package(c, |s, p| { for_each_package(c, |s, p| {
if p.name == name { if p.name == name {
@ -986,7 +978,7 @@ fn install_named(c: &Cargo, wd: &Path, name: ~str) {
} }
} }
fn install_uuid_specific(c: &Cargo, wd: &Path, src: ~str, uuid: ~str) { pub fn install_uuid_specific(c: &Cargo, wd: &Path, src: ~str, uuid: ~str) {
match c.sources.find(src) { match c.sources.find(src) {
Some(s) => { Some(s) => {
for s.packages.each |p| { for s.packages.each |p| {
@ -1001,7 +993,7 @@ fn install_uuid_specific(c: &Cargo, wd: &Path, src: ~str, uuid: ~str) {
error(~"can't find package: " + src + ~"/" + uuid); error(~"can't find package: " + src + ~"/" + uuid);
} }
fn install_named_specific(c: &Cargo, wd: &Path, src: ~str, name: ~str) { pub fn install_named_specific(c: &Cargo, wd: &Path, src: ~str, name: ~str) {
match c.sources.find(src) { match c.sources.find(src) {
Some(s) => { Some(s) => {
for s.packages.each |p| { for s.packages.each |p| {
@ -1016,7 +1008,7 @@ fn install_named_specific(c: &Cargo, wd: &Path, src: ~str, name: ~str) {
error(~"can't find package: " + src + ~"/" + name); error(~"can't find package: " + src + ~"/" + name);
} }
fn cmd_uninstall(c: &Cargo) { pub fn cmd_uninstall(c: &Cargo) {
if vec::len(c.opts.free) < 3u { if vec::len(c.opts.free) < 3u {
cmd_usage(); cmd_usage();
return; return;
@ -1068,7 +1060,7 @@ fn cmd_uninstall(c: &Cargo) {
} }
} }
fn install_query(c: &Cargo, wd: &Path, target: ~str) { pub fn install_query(c: &Cargo, wd: &Path, target: ~str) {
match c.dep_cache.find(target) { match c.dep_cache.find(target) {
Some(inst) => { Some(inst) => {
if inst { if inst {
@ -1128,7 +1120,7 @@ fn install_query(c: &Cargo, wd: &Path, target: ~str) {
} }
} }
fn get_temp_workdir(c: &Cargo) -> Path { pub fn get_temp_workdir(c: &Cargo) -> Path {
match tempfile::mkdtemp(&c.workdir, "cargo") { match tempfile::mkdtemp(&c.workdir, "cargo") {
Some(wd) => wd, Some(wd) => wd,
None => fail fmt!("needed temp dir: %s", None => fail fmt!("needed temp dir: %s",
@ -1136,7 +1128,7 @@ fn get_temp_workdir(c: &Cargo) -> Path {
} }
} }
fn cmd_install(c: &Cargo) { pub fn cmd_install(c: &Cargo) {
unsafe { unsafe {
let wd = get_temp_workdir(c); let wd = get_temp_workdir(c);
@ -1162,7 +1154,7 @@ fn cmd_install(c: &Cargo) {
} }
} }
fn sync(c: &Cargo) { pub fn sync(c: &Cargo) {
for c.sources.each_key |k| { for c.sources.each_key |k| {
let mut s = c.sources.get(k); let mut s = c.sources.get(k);
sync_one(c, s); sync_one(c, s);
@ -1170,7 +1162,7 @@ fn sync(c: &Cargo) {
} }
} }
fn sync_one_file(c: &Cargo, dir: &Path, src: @Source) -> bool { pub fn sync_one_file(c: &Cargo, dir: &Path, src: @Source) -> bool {
let name = src.name; let name = src.name;
let srcfile = dir.push("source.json.new"); let srcfile = dir.push("source.json.new");
let destsrcfile = dir.push("source.json"); let destsrcfile = dir.push("source.json");
@ -1248,7 +1240,7 @@ fn sync_one_file(c: &Cargo, dir: &Path, src: @Source) -> bool {
return true; return true;
} }
fn sync_one_git(c: &Cargo, dir: &Path, src: @Source) -> bool { pub fn sync_one_git(c: &Cargo, dir: &Path, src: @Source) -> bool {
let name = src.name; let name = src.name;
let srcfile = dir.push("source.json"); let srcfile = dir.push("source.json");
let pkgfile = dir.push("packages.json"); let pkgfile = dir.push("packages.json");
@ -1351,7 +1343,7 @@ fn sync_one_git(c: &Cargo, dir: &Path, src: @Source) -> bool {
return true; return true;
} }
fn sync_one_curl(c: &Cargo, dir: &Path, src: @Source) -> bool { pub fn sync_one_curl(c: &Cargo, dir: &Path, src: @Source) -> bool {
let name = src.name; let name = src.name;
let srcfile = dir.push("source.json.new"); let srcfile = dir.push("source.json.new");
let destsrcfile = dir.push("source.json"); let destsrcfile = dir.push("source.json");
@ -1467,7 +1459,7 @@ fn sync_one_curl(c: &Cargo, dir: &Path, src: @Source) -> bool {
return true; return true;
} }
fn sync_one(c: &Cargo, src: @Source) { pub fn sync_one(c: &Cargo, src: @Source) {
let name = src.name; let name = src.name;
let dir = c.sourcedir.push(name); let dir = c.sourcedir.push(name);
@ -1487,7 +1479,7 @@ fn sync_one(c: &Cargo, src: @Source) {
} }
} }
fn cmd_init(c: &Cargo) { pub fn cmd_init(c: &Cargo) {
let srcurl = ~"http://www.rust-lang.org/cargo/sources.json"; let srcurl = ~"http://www.rust-lang.org/cargo/sources.json";
let sigurl = ~"http://www.rust-lang.org/cargo/sources.json.sig"; let sigurl = ~"http://www.rust-lang.org/cargo/sources.json.sig";
@ -1525,7 +1517,7 @@ fn cmd_init(c: &Cargo) {
info(fmt!("initialized .cargo in %s", c.root.to_str())); info(fmt!("initialized .cargo in %s", c.root.to_str()));
} }
fn print_pkg(s: @Source, p: &Package) { pub fn print_pkg(s: @Source, p: &Package) {
let mut m = s.name + ~"/" + p.name + ~" (" + p.uuid + ~")"; let mut m = s.name + ~"/" + p.name + ~" (" + p.uuid + ~")";
if vec::len(p.tags) > 0u { if vec::len(p.tags) > 0u {
m = m + ~" [" + str::connect(p.tags, ~", ") + ~"]"; m = m + ~" [" + str::connect(p.tags, ~", ") + ~"]";
@ -1536,7 +1528,7 @@ fn print_pkg(s: @Source, p: &Package) {
} }
} }
fn print_source(s: @Source) { pub fn print_source(s: @Source) {
info(s.name + ~" (" + s.url + ~")"); info(s.name + ~" (" + s.url + ~")");
let pks = sort::merge_sort(s.packages.get(), sys::shape_lt); let pks = sort::merge_sort(s.packages.get(), sys::shape_lt);
@ -1557,7 +1549,7 @@ fn print_source(s: @Source) {
})); }));
} }
fn cmd_list(c: &Cargo) { pub fn cmd_list(c: &Cargo) {
sync(c); sync(c);
if vec::len(c.opts.free) >= 3u { if vec::len(c.opts.free) >= 3u {
@ -1583,7 +1575,7 @@ fn cmd_list(c: &Cargo) {
} }
} }
fn cmd_search(c: &Cargo) { pub fn cmd_search(c: &Cargo) {
if vec::len(c.opts.free) < 3u { if vec::len(c.opts.free) < 3u {
cmd_usage(); cmd_usage();
return; return;
@ -1604,7 +1596,7 @@ fn cmd_search(c: &Cargo) {
info(fmt!("found %d packages", n)); info(fmt!("found %d packages", n));
} }
fn install_to_dir(srcfile: &Path, destdir: &Path) { pub fn install_to_dir(srcfile: &Path, destdir: &Path) {
let newfile = destdir.push(srcfile.filename().get()); let newfile = destdir.push(srcfile.filename().get());
let status = run::run_program(~"cp", ~[~"-r", srcfile.to_str(), let status = run::run_program(~"cp", ~[~"-r", srcfile.to_str(),
@ -1616,7 +1608,7 @@ fn install_to_dir(srcfile: &Path, destdir: &Path) {
} }
} }
fn dump_cache(c: &Cargo) { pub fn dump_cache(c: &Cargo) {
need_dir(&c.root); need_dir(&c.root);
let out = c.root.push("cache.json"); let out = c.root.push("cache.json");
@ -1626,7 +1618,8 @@ fn dump_cache(c: &Cargo) {
copy_warn(&out, &c.root.push("cache.json.old")); copy_warn(&out, &c.root.push("cache.json.old"));
} }
} }
fn dump_sources(c: &Cargo) {
pub fn dump_sources(c: &Cargo) {
if c.sources.size() < 1u { if c.sources.size() < 1u {
return; return;
} }
@ -1673,14 +1666,14 @@ fn dump_sources(c: &Cargo) {
} }
} }
fn copy_warn(srcfile: &Path, destfile: &Path) { pub fn copy_warn(srcfile: &Path, destfile: &Path) {
if !os::copy_file(srcfile, destfile) { if !os::copy_file(srcfile, destfile) {
warn(fmt!("copying %s to %s failed", warn(fmt!("copying %s to %s failed",
srcfile.to_str(), destfile.to_str())); srcfile.to_str(), destfile.to_str()));
} }
} }
fn cmd_sources(c: &Cargo) { pub fn cmd_sources(c: &Cargo) {
if vec::len(c.opts.free) < 3u { if vec::len(c.opts.free) < 3u {
for c.sources.each_value |v| { for c.sources.each_value |v| {
info(fmt!("%s (%s) via %s", info(fmt!("%s (%s) via %s",
@ -1845,7 +1838,7 @@ fn cmd_sources(c: &Cargo) {
} }
} }
fn cmd_usage() { pub fn cmd_usage() {
print(~"Usage: cargo <cmd> [options] [args..] print(~"Usage: cargo <cmd> [options] [args..]
e.g. cargo install <name> e.g. cargo install <name>
@ -1860,14 +1853,14 @@ Options:
"); ");
} }
fn cmd_usage_init() { pub fn cmd_usage_init() {
print(~"cargo init print(~"cargo init
Re-initialize cargo in ~/.cargo. Clears all sources and then adds the Re-initialize cargo in ~/.cargo. Clears all sources and then adds the
default sources from <www.rust-lang.org/sources.json>."); default sources from <www.rust-lang.org/sources.json>.");
} }
fn cmd_usage_install() { pub fn cmd_usage_install() {
print(~"cargo install print(~"cargo install
cargo install [source/]<name>[@version] cargo install [source/]<name>[@version]
cargo install [source/]<uuid>[@version] cargo install [source/]<uuid>[@version]
@ -1886,7 +1879,7 @@ the current working directory. If a source is provided, only install
from that source, otherwise it installs from any source."); from that source, otherwise it installs from any source.");
} }
fn cmd_usage_uninstall() { pub fn cmd_usage_uninstall() {
print(~"cargo uninstall [source/]<name>[@version] print(~"cargo uninstall [source/]<name>[@version]
cargo uninstall [source/]<uuid>[@version] cargo uninstall [source/]<uuid>[@version]
cargo uninstall <meta-name>[@version] cargo uninstall <meta-name>[@version]
@ -1903,7 +1896,7 @@ If a crate was installed directly (git, tarball, etc.), you can remove
it by metadata."); it by metadata.");
} }
fn cmd_usage_list() { pub fn cmd_usage_list() {
print(~"cargo list [sources..] print(~"cargo list [sources..]
If no arguments are provided, list all sources and their packages. If no arguments are provided, list all sources and their packages.
@ -1911,13 +1904,13 @@ If source names are provided, list those sources and their packages.
"); ");
} }
fn cmd_usage_search() { pub fn cmd_usage_search() {
print(~"cargo search <query | '*'> [tags..] print(~"cargo search <query | '*'> [tags..]
Search packages."); Search packages.");
} }
fn cmd_usage_sources() { pub fn cmd_usage_sources() {
print(~"cargo sources print(~"cargo sources
cargo sources add <name> <url> cargo sources add <name> <url>
cargo sources remove <name> cargo sources remove <name>
@ -1936,7 +1929,7 @@ Commands:
set-method Change the method for a source."); set-method Change the method for a source.");
} }
fn main() { pub fn main() {
let argv = os::args(); let argv = os::args();
let o = build_cargo_options(argv); let o = build_cargo_options(argv);
@ -1987,3 +1980,4 @@ fn main() {
dump_cache(c); dump_cache(c);
dump_sources(c); dump_sources(c);
} }

View file

@ -12,11 +12,11 @@ use core::os;
use core::path::Path; use core::path::Path;
use core::run; use core::run;
fn gpgv(args: ~[~str]) -> { status: int, out: ~str, err: ~str } { pub fn gpgv(args: ~[~str]) -> { status: int, out: ~str, err: ~str } {
return run::program_output(~"gpgv", args); return run::program_output(~"gpgv", args);
} }
fn signing_key() -> ~str { pub fn signing_key() -> ~str {
~" ~"
-----BEGIN PGP PUBLIC KEY BLOCK----- -----BEGIN PGP PUBLIC KEY BLOCK-----
Version: SKS 1.1.0 Version: SKS 1.1.0
@ -68,16 +68,16 @@ HI1jilzwKSXuV2EmyBk3tKh9NwscT/A78pr30FxxPUg3v72raNgusTo=
" "
} }
fn signing_key_fp() -> ~str { pub fn signing_key_fp() -> ~str {
~"FE79 EDB0 3DEF B0D8 27D2 6C41 0B2D 6A28 3033 6376" ~"FE79 EDB0 3DEF B0D8 27D2 6C41 0B2D 6A28 3033 6376"
} }
fn supported() -> bool { pub fn supported() -> bool {
let r = gpgv(~[~"--version"]); let r = gpgv(~[~"--version"]);
r.status == 0 r.status == 0
} }
fn init(root: &Path) { pub fn init(root: &Path) {
let p = root.push("gpg"); let p = root.push("gpg");
if !os::path_is_dir(&p) { if !os::path_is_dir(&p) {
os::make_dir(&p, 0x1c0i32); os::make_dir(&p, 0x1c0i32);
@ -92,7 +92,7 @@ fn init(root: &Path) {
} }
} }
fn add(root: &Path, key: &Path) { pub fn add(root: &Path, key: &Path) {
let path = root.push("gpg"); let path = root.push("gpg");
let p = let p =
run::program_output(~"gpg", ~[~"--homedir", path.to_str(), run::program_output(~"gpg", ~[~"--homedir", path.to_str(),
@ -102,7 +102,7 @@ fn add(root: &Path, key: &Path) {
} }
} }
fn verify(root: &Path, data: &Path, sig: &Path) -> bool { pub fn verify(root: &Path, data: &Path, sig: &Path) -> bool {
let path = root.push("gpg"); let path = root.push("gpg");
let res = gpgv(~[~"--homedir", path.to_str(), let res = gpgv(~[~"--homedir", path.to_str(),
~"--keyring", ~"pubring.gpg", ~"--keyring", ~"pubring.gpg",

View file

@ -20,7 +20,6 @@
#[no_core]; #[no_core];
#[legacy_modes]; #[legacy_modes];
#[legacy_exports];
#[allow(vecs_implicitly_copyable)]; #[allow(vecs_implicitly_copyable)];
#[allow(non_camel_case_types)]; #[allow(non_camel_case_types)];
@ -40,27 +39,22 @@ use syntax::parse;
use syntax::print::pprust; use syntax::print::pprust;
use syntax::diagnostic; use syntax::diagnostic;
enum test_mode { tm_converge, tm_run, } #[deriving_eq]
struct Context { mode: test_mode } // + rng pub enum test_mode { tm_converge, tm_run, }
impl test_mode : cmp::Eq { pub struct Context { mode: test_mode } // + rng
pure fn eq(&self, other: &test_mode) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(&self, other: &test_mode) -> bool { !(*self).eq(other) }
}
fn write_file(filename: &Path, content: ~str) { pub fn write_file(filename: &Path, content: ~str) {
result::get( result::get(
&io::file_writer(filename, ~[io::Create, io::Truncate])) &io::file_writer(filename, ~[io::Create, io::Truncate]))
.write_str(content); .write_str(content);
} }
fn contains(haystack: ~str, needle: ~str) -> bool { pub fn contains(haystack: ~str, needle: ~str) -> bool {
str::contains(haystack, needle) str::contains(haystack, needle)
} }
fn find_rust_files(files: &mut ~[Path], path: &Path) { pub fn find_rust_files(files: &mut ~[Path], path: &Path) {
if path.filetype() == Some(~".rs") && !contains(path.to_str(), ~"utf8") { if path.filetype() == Some(~".rs") && !contains(path.to_str(), ~"utf8") {
// ignoring "utf8" tests because something is broken // ignoring "utf8" tests because something is broken
files.push(*path); files.push(*path);
@ -74,7 +68,7 @@ fn find_rust_files(files: &mut ~[Path], path: &Path) {
} }
fn common_exprs() -> ~[ast::expr] { pub fn common_exprs() -> ~[ast::expr] {
fn dse(e: ast::expr_) -> ast::expr { fn dse(e: ast::expr_) -> ast::expr {
ast::expr { ast::expr {
id: 0, id: 0,
@ -104,11 +98,11 @@ fn common_exprs() -> ~[ast::expr] {
] ]
} }
pure fn safe_to_steal_expr(e: @ast::expr, tm: test_mode) -> bool { pub pure fn safe_to_steal_expr(e: @ast::expr, tm: test_mode) -> bool {
safe_to_use_expr(*e, tm) safe_to_use_expr(*e, tm)
} }
pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool { pub pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool {
match tm { match tm {
tm_converge => { tm_converge => {
match e.node { match e.node {
@ -142,33 +136,37 @@ pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool {
} }
} }
fn safe_to_steal_ty(t: @ast::Ty, tm: test_mode) -> bool { pub fn safe_to_steal_ty(t: @ast::Ty, tm: test_mode) -> bool {
// Restrictions happen to be the same. // Restrictions happen to be the same.
safe_to_replace_ty(t.node, tm) safe_to_replace_ty(t.node, tm)
} }
// Not type-parameterized: https://github.com/mozilla/rust/issues/898 (FIXED) // Not type-parameterized: https://github.com/mozilla/rust/issues/898 (FIXED)
fn stash_expr_if(c: fn@(@ast::expr, test_mode)->bool, pub fn stash_expr_if(c: fn@(@ast::expr, test_mode)->bool,
es: @mut ~[ast::expr], es: @mut ~[ast::expr],
e: @ast::expr, e: @ast::expr,
tm: test_mode) { tm: test_mode) {
if c(e, tm) { if c(e, tm) {
*es += ~[*e]; *es += ~[*e];
} else {/* now my indices are wrong :( */ } } else {
/* now my indices are wrong :( */
}
} }
fn stash_ty_if(c: fn@(@ast::Ty, test_mode)->bool, pub fn stash_ty_if(c: fn@(@ast::Ty, test_mode)->bool,
es: @mut ~[ast::Ty], es: @mut ~[ast::Ty],
e: @ast::Ty, e: @ast::Ty,
tm: test_mode) { tm: test_mode) {
if c(e, tm) { if c(e, tm) {
es.push(*e); es.push(*e);
} else {/* now my indices are wrong :( */ } } else {
/* now my indices are wrong :( */
}
} }
struct StolenStuff {exprs: ~[ast::expr], tys: ~[ast::Ty]} pub struct StolenStuff {exprs: ~[ast::expr], tys: ~[ast::Ty]}
fn steal(crate: ast::crate, tm: test_mode) -> StolenStuff { pub fn steal(crate: ast::crate, tm: test_mode) -> StolenStuff {
let exprs = @mut ~[]; let exprs = @mut ~[];
let tys = @mut ~[]; let tys = @mut ~[];
let v = visit::mk_simple_visitor(@visit::SimpleVisitor { let v = visit::mk_simple_visitor(@visit::SimpleVisitor {
@ -181,7 +179,7 @@ fn steal(crate: ast::crate, tm: test_mode) -> StolenStuff {
} }
fn safe_to_replace_expr(e: ast::expr_, _tm: test_mode) -> bool { pub fn safe_to_replace_expr(e: ast::expr_, _tm: test_mode) -> bool {
match e { match e {
// https://github.com/mozilla/rust/issues/652 // https://github.com/mozilla/rust/issues/652
ast::expr_if(*) => { false } ast::expr_if(*) => { false }
@ -194,7 +192,7 @@ fn safe_to_replace_expr(e: ast::expr_, _tm: test_mode) -> bool {
} }
} }
fn safe_to_replace_ty(t: ast::ty_, _tm: test_mode) -> bool { pub fn safe_to_replace_ty(t: ast::ty_, _tm: test_mode) -> bool {
match t { match t {
ast::ty_infer => { false } // always implicit, always top level ast::ty_infer => { false } // always implicit, always top level
ast::ty_bot => { false } // in source, can only appear ast::ty_bot => { false } // in source, can only appear
@ -205,8 +203,8 @@ fn safe_to_replace_ty(t: ast::ty_, _tm: test_mode) -> bool {
} }
// Replace the |i|th expr (in fold order) of |crate| with |newexpr|. // Replace the |i|th expr (in fold order) of |crate| with |newexpr|.
fn replace_expr_in_crate(crate: ast::crate, i: uint, pub fn replace_expr_in_crate(crate: ast::crate, i: uint,
newexpr: ast::expr, tm: test_mode) -> newexpr: ast::expr, tm: test_mode) ->
ast::crate { ast::crate {
let j: @mut uint = @mut 0u; let j: @mut uint = @mut 0u;
fn fold_expr_rep(j_: @mut uint, i_: uint, newexpr_: ast::expr_, fn fold_expr_rep(j_: @mut uint, i_: uint, newexpr_: ast::expr_,
@ -233,8 +231,8 @@ fn replace_expr_in_crate(crate: ast::crate, i: uint,
// Replace the |i|th ty (in fold order) of |crate| with |newty|. // Replace the |i|th ty (in fold order) of |crate| with |newty|.
fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::Ty, pub fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::Ty,
tm: test_mode) -> ast::crate { tm: test_mode) -> ast::crate {
let j: @mut uint = @mut 0u; let j: @mut uint = @mut 0u;
fn fold_ty_rep(j_: @mut uint, i_: uint, newty_: ast::ty_, fn fold_ty_rep(j_: @mut uint, i_: uint, newty_: ast::ty_,
original: ast::ty_, fld: fold::ast_fold, original: ast::ty_, fld: fold::ast_fold,
@ -254,17 +252,17 @@ fn replace_ty_in_crate(crate: ast::crate, i: uint, newty: ast::Ty,
*crate2 *crate2
} }
fn under(n: uint, it: fn(uint)) { pub fn under(n: uint, it: fn(uint)) {
let mut i: uint = 0u; let mut i: uint = 0u;
while i < n { it(i); i += 1u; } while i < n { it(i); i += 1u; }
} }
fn as_str(f: fn@(+x: io::Writer)) -> ~str { pub fn as_str(f: fn@(+x: io::Writer)) -> ~str {
io::with_str_writer(f) io::with_str_writer(f)
} }
fn check_variants_of_ast(crate: ast::crate, codemap: @codemap::CodeMap, pub fn check_variants_of_ast(crate: ast::crate, codemap: @codemap::CodeMap,
filename: &Path, cx: Context) { filename: &Path, cx: Context) {
let stolen = steal(crate, cx.mode); let stolen = steal(crate, cx.mode);
let extra_exprs = do common_exprs().filtered |a| { let extra_exprs = do common_exprs().filtered |a| {
safe_to_use_expr(*a, cx.mode) safe_to_use_expr(*a, cx.mode)
@ -276,7 +274,7 @@ fn check_variants_of_ast(crate: ast::crate, codemap: @codemap::CodeMap,
pprust::ty_to_str, replace_ty_in_crate, cx); pprust::ty_to_str, replace_ty_in_crate, cx);
} }
fn check_variants_T<T: Copy>( pub fn check_variants_T<T: Copy>(
crate: ast::crate, crate: ast::crate,
codemap: @codemap::CodeMap, codemap: @codemap::CodeMap,
filename: &Path, filename: &Path,
@ -334,12 +332,12 @@ fn check_variants_T<T: Copy>(
} }
} }
fn last_part(filename: ~str) -> ~str { pub fn last_part(filename: ~str) -> ~str {
let ix = option::get(str::rfind_char(filename, '/')); let ix = option::get(str::rfind_char(filename, '/'));
str::slice(filename, ix + 1u, str::len(filename) - 3u) str::slice(filename, ix + 1u, str::len(filename) - 3u)
} }
enum happiness { pub enum happiness {
passed, passed,
cleanly_rejected(~str), cleanly_rejected(~str),
known_bug(~str), known_bug(~str),
@ -351,8 +349,8 @@ enum happiness {
// - that would be tricky, requiring use of tasks or serialization // - that would be tricky, requiring use of tasks or serialization
// or randomness. // or randomness.
// This seems to find plenty of bugs as it is :) // This seems to find plenty of bugs as it is :)
fn check_whole_compiler(code: ~str, suggested_filename_prefix: &Path, pub fn check_whole_compiler(code: ~str, suggested_filename_prefix: &Path,
allow_running: bool) { allow_running: bool) {
let filename = &suggested_filename_prefix.with_filetype("rs"); let filename = &suggested_filename_prefix.with_filetype("rs");
write_file(filename, code); write_file(filename, code);
@ -376,19 +374,19 @@ fn check_whole_compiler(code: ~str, suggested_filename_prefix: &Path,
} }
} }
fn removeIfExists(filename: &Path) { pub fn removeIfExists(filename: &Path) {
// So sketchy! // So sketchy!
assert !contains(filename.to_str(), ~" "); assert !contains(filename.to_str(), ~" ");
run::program_output(~"bash", ~[~"-c", ~"rm " + filename.to_str()]); run::program_output(~"bash", ~[~"-c", ~"rm " + filename.to_str()]);
} }
fn removeDirIfExists(filename: &Path) { pub fn removeDirIfExists(filename: &Path) {
// So sketchy! // So sketchy!
assert !contains(filename.to_str(), ~" "); assert !contains(filename.to_str(), ~" ");
run::program_output(~"bash", ~[~"-c", ~"rm -r " + filename.to_str()]); run::program_output(~"bash", ~[~"-c", ~"rm -r " + filename.to_str()]);
} }
fn check_running(exe_filename: &Path) -> happiness { pub fn check_running(exe_filename: &Path) -> happiness {
let p = run::program_output( let p = run::program_output(
~"/Users/jruderman/scripts/timed_run_rust_program.py", ~"/Users/jruderman/scripts/timed_run_rust_program.py",
~[exe_filename.to_str()]); ~[exe_filename.to_str()]);
@ -427,7 +425,7 @@ fn check_running(exe_filename: &Path) -> happiness {
} }
} }
fn check_compiling(filename: &Path) -> happiness { pub fn check_compiling(filename: &Path) -> happiness {
let p = run::program_output( let p = run::program_output(
~"/Users/jruderman/code/rust/build/x86_64-apple-darwin/\ ~"/Users/jruderman/code/rust/build/x86_64-apple-darwin/\
stage1/bin/rustc", stage1/bin/rustc",
@ -460,7 +458,7 @@ fn check_compiling(filename: &Path) -> happiness {
} }
fn parse_and_print(code: @~str) -> ~str { pub fn parse_and_print(code: @~str) -> ~str {
let filename = Path("tmp.rs"); let filename = Path("tmp.rs");
let sess = parse::new_parse_sess(option::None); let sess = parse::new_parse_sess(option::None);
write_file(&filename, *code); write_file(&filename, *code);
@ -481,7 +479,7 @@ fn parse_and_print(code: @~str) -> ~str {
} }
} }
fn has_raw_pointers(c: ast::crate) -> bool { pub fn has_raw_pointers(c: ast::crate) -> bool {
let has_rp = @mut false; let has_rp = @mut false;
fn visit_ty(flag: @mut bool, t: @ast::Ty) { fn visit_ty(flag: @mut bool, t: @ast::Ty) {
match t.node { match t.node {
@ -497,7 +495,7 @@ fn has_raw_pointers(c: ast::crate) -> bool {
return *has_rp; return *has_rp;
} }
fn content_is_dangerous_to_run(code: ~str) -> bool { pub fn content_is_dangerous_to_run(code: ~str) -> bool {
let dangerous_patterns = let dangerous_patterns =
~[~"xfail-test", ~[~"xfail-test",
~"import", // espeically fs, run ~"import", // espeically fs, run
@ -509,7 +507,7 @@ fn content_is_dangerous_to_run(code: ~str) -> bool {
return false; return false;
} }
fn content_is_dangerous_to_compile(code: ~str) -> bool { pub fn content_is_dangerous_to_compile(code: ~str) -> bool {
let dangerous_patterns = let dangerous_patterns =
~[~"xfail-test"]; ~[~"xfail-test"];
@ -517,7 +515,7 @@ fn content_is_dangerous_to_compile(code: ~str) -> bool {
return false; return false;
} }
fn content_might_not_converge(code: ~str) -> bool { pub fn content_might_not_converge(code: ~str) -> bool {
let confusing_patterns = let confusing_patterns =
~[~"xfail-test", ~[~"xfail-test",
~"xfail-pretty", ~"xfail-pretty",
@ -533,7 +531,7 @@ fn content_might_not_converge(code: ~str) -> bool {
return false; return false;
} }
fn file_might_not_converge(filename: &Path) -> bool { pub fn file_might_not_converge(filename: &Path) -> bool {
let confusing_files = ~[ let confusing_files = ~[
~"expr-alt.rs", // pretty-printing "(a = b) = c" ~"expr-alt.rs", // pretty-printing "(a = b) = c"
// vs "a = b = c" and wrapping // vs "a = b = c" and wrapping
@ -552,7 +550,7 @@ fn file_might_not_converge(filename: &Path) -> bool {
return false; return false;
} }
fn check_roundtrip_convergence(code: @~str, maxIters: uint) { pub fn check_roundtrip_convergence(code: @~str, maxIters: uint) {
let mut i = 0u; let mut i = 0u;
let mut newv = code; let mut newv = code;
@ -579,7 +577,7 @@ fn check_roundtrip_convergence(code: @~str, maxIters: uint) {
} }
} }
fn check_convergence(files: &[Path]) { pub fn check_convergence(files: &[Path]) {
error!("pp convergence tests: %u files", vec::len(files)); error!("pp convergence tests: %u files", vec::len(files));
for files.each |file| { for files.each |file| {
if !file_might_not_converge(file) { if !file_might_not_converge(file) {
@ -594,7 +592,7 @@ fn check_convergence(files: &[Path]) {
} }
} }
fn check_variants(files: &[Path], cx: Context) { pub fn check_variants(files: &[Path], cx: Context) {
for files.each |file| { for files.each |file| {
if cx.mode == tm_converge && if cx.mode == tm_converge &&
file_might_not_converge(file) { file_might_not_converge(file) {
@ -639,7 +637,7 @@ fn check_variants(files: &[Path], cx: Context) {
} }
} }
fn main() { pub fn main() {
let args = os::args(); let args = os::args();
if vec::len(args) != 2u { if vec::len(args) != 2u {
error!("usage: %s <testdir>", args[0]); error!("usage: %s <testdir>", args[0]);

View file

@ -75,7 +75,6 @@ fn take_my_order_please(
} }
mod fortress_of_solitude { mod fortress_of_solitude {
#[legacy_exports];
/*! /*!
* Superman's vacation home * Superman's vacation home
* *
@ -90,7 +89,6 @@ mod fortress_of_solitude {
} }
mod blade_runner { mod blade_runner {
#[legacy_exports];
/*! /*!
* Blade Runner is probably the best movie ever * Blade Runner is probably the best movie ever
* *

View file

@ -343,8 +343,6 @@ fn should_extract_struct_fields() {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
#[legacy_exports];
use astsrv; use astsrv;
use doc; use doc;
use extract::{extract, from_srv}; use extract::{extract, from_srv};
@ -352,20 +350,20 @@ mod test {
use core::vec; use core::vec;
fn mk_doc(+source: ~str) -> doc::Doc { pub fn mk_doc(+source: ~str) -> doc::Doc {
let ast = parse::from_str(source); let ast = parse::from_str(source);
extract(ast, ~"") extract(ast, ~"")
} }
#[test] #[test]
fn extract_empty_crate() { pub fn extract_empty_crate() {
let doc = mk_doc(~""); let doc = mk_doc(~"");
assert vec::is_empty(doc.cratemod().mods()); assert vec::is_empty(doc.cratemod().mods());
assert vec::is_empty(doc.cratemod().fns()); assert vec::is_empty(doc.cratemod().fns());
} }
#[test] #[test]
fn extract_mods() { pub fn extract_mods() {
let doc = mk_doc(~"mod a { mod b { } mod c { } }"); let doc = mk_doc(~"mod a { mod b { } mod c { } }");
assert doc.cratemod().mods()[0].name() == ~"a"; assert doc.cratemod().mods()[0].name() == ~"a";
assert doc.cratemod().mods()[0].mods()[0].name() == ~"b"; assert doc.cratemod().mods()[0].mods()[0].name() == ~"b";
@ -373,47 +371,47 @@ mod test {
} }
#[test] #[test]
fn extract_foreign_mods() { pub fn extract_foreign_mods() {
let doc = mk_doc(~"extern mod a { }"); let doc = mk_doc(~"extern mod a { }");
assert doc.cratemod().nmods()[0].name() == ~"a"; assert doc.cratemod().nmods()[0].name() == ~"a";
} }
#[test] #[test]
fn extract_fns_from_foreign_mods() { pub fn extract_fns_from_foreign_mods() {
let doc = mk_doc(~"extern mod a { fn a(); }"); let doc = mk_doc(~"extern mod a { fn a(); }");
assert doc.cratemod().nmods()[0].fns[0].name() == ~"a"; assert doc.cratemod().nmods()[0].fns[0].name() == ~"a";
} }
#[test] #[test]
fn extract_mods_deep() { pub fn extract_mods_deep() {
let doc = mk_doc(~"mod a { mod b { mod c { } } }"); let doc = mk_doc(~"mod a { mod b { mod c { } } }");
assert doc.cratemod().mods()[0].mods()[0].mods()[0].name() == ~"c"; assert doc.cratemod().mods()[0].mods()[0].mods()[0].name() == ~"c";
} }
#[test] #[test]
fn extract_should_set_mod_ast_id() { pub fn extract_should_set_mod_ast_id() {
let doc = mk_doc(~"mod a { }"); let doc = mk_doc(~"mod a { }");
assert doc.cratemod().mods()[0].id() != 0; assert doc.cratemod().mods()[0].id() != 0;
} }
#[test] #[test]
fn extract_fns() { pub fn extract_fns() {
let doc = mk_doc( let doc = mk_doc(
~"fn a() { } \ ~"fn a() { } \
mod b { mod b {
#[legacy_exports]; fn c() { } }"); } }");
assert doc.cratemod().fns()[0].name() == ~"a"; assert doc.cratemod().fns()[0].name() == ~"a";
assert doc.cratemod().mods()[0].fns()[0].name() == ~"c"; assert doc.cratemod().mods()[0].fns()[0].name() == ~"c";
} }
#[test] #[test]
fn extract_should_set_fn_ast_id() { pub fn extract_should_set_fn_ast_id() {
let doc = mk_doc(~"fn a() { }"); let doc = mk_doc(~"fn a() { }");
assert doc.cratemod().fns()[0].id() != 0; assert doc.cratemod().fns()[0].id() != 0;
} }
#[test] #[test]
fn extract_should_use_default_crate_name() { pub fn extract_should_use_default_crate_name() {
let source = ~""; let source = ~"";
let ast = parse::from_str(source); let ast = parse::from_str(source);
let doc = extract(ast, ~"burp"); let doc = extract(ast, ~"burp");
@ -421,7 +419,7 @@ mod test {
} }
#[test] #[test]
fn extract_from_seq_srv() { pub fn extract_from_seq_srv() {
let source = ~""; let source = ~"";
do astsrv::from_str(source) |srv| { do astsrv::from_str(source) |srv| {
let doc = from_srv(srv, ~"name"); let doc = from_srv(srv, ~"name");

View file

@ -96,7 +96,7 @@ fn should_write_modules_last() {
~"mod a { }\ ~"mod a { }\
fn b() { }\ fn b() { }\
mod c { mod c {
#[legacy_exports]; }\ }\
fn d() { }" fn d() { }"
); );
@ -371,7 +371,7 @@ fn should_write_sections() {
# Header\n\ # Header\n\
Body\"]\ Body\"]\
mod a { mod a {
#[legacy_exports]; }"); }");
assert str::contains(markdown, ~"#### Header\n\nBody\n\n"); assert str::contains(markdown, ~"#### Header\n\nBody\n\n");
} }
@ -832,8 +832,6 @@ fn should_write_struct_header() {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
#[legacy_exports];
use astsrv; use astsrv;
use attr_pass; use attr_pass;
use config; use config;
@ -853,14 +851,14 @@ mod test {
use core::path::Path; use core::path::Path;
use core::str; use core::str;
fn render(+source: ~str) -> ~str { pub fn render(+source: ~str) -> ~str {
let (srv, doc) = create_doc_srv(source); let (srv, doc) = create_doc_srv(source);
let markdown = write_markdown_str_srv(srv, doc); let markdown = write_markdown_str_srv(srv, doc);
debug!("markdown: %s", markdown); debug!("markdown: %s", markdown);
markdown markdown
} }
fn create_doc_srv(+source: ~str) -> (astsrv::Srv, doc::Doc) { pub fn create_doc_srv(+source: ~str) -> (astsrv::Srv, doc::Doc) {
do astsrv::from_str(source) |srv| { do astsrv::from_str(source) |srv| {
let config = config::Config { let config = config::Config {
@ -890,12 +888,12 @@ mod test {
} }
} }
fn create_doc(+source: ~str) -> doc::Doc { pub fn create_doc(+source: ~str) -> doc::Doc {
let (_, doc) = create_doc_srv(source); let (_, doc) = create_doc_srv(source);
doc doc
} }
fn write_markdown_str( pub fn write_markdown_str(
+doc: doc::Doc +doc: doc::Doc
) -> ~str { ) -> ~str {
let (writer_factory, po) = markdown_writer::future_writer_factory(); let (writer_factory, po) = markdown_writer::future_writer_factory();
@ -903,7 +901,7 @@ mod test {
return oldcomm::recv(po).second(); return oldcomm::recv(po).second();
} }
fn write_markdown_str_srv( pub fn write_markdown_str_srv(
srv: astsrv::Srv, srv: astsrv::Srv,
+doc: doc::Doc +doc: doc::Doc
) -> ~str { ) -> ~str {
@ -914,13 +912,13 @@ mod test {
} }
#[test] #[test]
fn write_markdown_should_write_mod_headers() { pub fn write_markdown_should_write_mod_headers() {
let markdown = render(~"mod moo { }"); let markdown = render(~"mod moo { }");
assert str::contains(markdown, ~"# Module `moo`"); assert str::contains(markdown, ~"# Module `moo`");
} }
#[test] #[test]
fn should_leave_blank_line_after_header() { pub fn should_leave_blank_line_after_header() {
let markdown = render(~"mod morp { }"); let markdown = render(~"mod morp { }");
assert str::contains(markdown, ~"Module `morp`\n\n"); assert str::contains(markdown, ~"Module `morp`\n\n");
} }

View file

@ -272,14 +272,12 @@ fn should_name_mod_file_names_by_path() {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
#[legacy_exports];
use astsrv; use astsrv;
use doc; use doc;
use extract; use extract;
use path_pass; use path_pass;
fn mk_doc(+name: ~str, +source: ~str) -> doc::Doc { pub fn mk_doc(+name: ~str, +source: ~str) -> doc::Doc {
do astsrv::from_str(source) |srv| { do astsrv::from_str(source) |srv| {
let doc = extract::from_srv(srv, name); let doc = extract::from_srv(srv, name);
let doc = (path_pass::mk_pass().f)(srv, doc); let doc = (path_pass::mk_pass().f)(srv, doc);

View file

@ -10,8 +10,6 @@
//! Prune things that are private //! Prune things that are private
#[legacy_exports];
use core::prelude::*; use core::prelude::*;
use astsrv; use astsrv;
@ -24,10 +22,7 @@ use core::util;
use core::vec; use core::vec;
use syntax::ast; use syntax::ast;
export mk_pass; pub fn mk_pass() -> Pass {
export run;
fn mk_pass() -> Pass {
Pass { Pass {
name: ~"prune_private", name: ~"prune_private",
f: run f: run

View file

@ -171,7 +171,7 @@ fn should_create_section_headers() {
# Header\n\ # Header\n\
Body\"]\ Body\"]\
mod a { mod a {
#[legacy_exports]; }"); }");
assert str::contains( assert str::contains(
doc.cratemod().mods()[0].item.sections[0].header, doc.cratemod().mods()[0].item.sections[0].header,
~"Header"); ~"Header");
@ -184,7 +184,7 @@ fn should_create_section_bodies() {
# Header\n\ # Header\n\
Body\"]\ Body\"]\
mod a { mod a {
#[legacy_exports]; }"); }");
assert str::contains( assert str::contains(
doc.cratemod().mods()[0].item.sections[0].body, doc.cratemod().mods()[0].item.sections[0].body,
~"Body"); ~"Body");
@ -197,7 +197,7 @@ fn should_not_create_sections_from_indented_headers() {
Text\n # Header\n\ Text\n # Header\n\
Body\"]\ Body\"]\
mod a { mod a {
#[legacy_exports]; }"); }");
assert vec::is_empty(doc.cratemod().mods()[0].item.sections); assert vec::is_empty(doc.cratemod().mods()[0].item.sections);
} }
@ -209,7 +209,7 @@ fn should_remove_section_text_from_main_desc() {
# Header\n\ # Header\n\
Body\"]\ Body\"]\
mod a { mod a {
#[legacy_exports]; }"); }");
assert !str::contains( assert !str::contains(
doc.cratemod().mods()[0].desc().get(), doc.cratemod().mods()[0].desc().get(),
~"Header"); ~"Header");
@ -225,7 +225,7 @@ fn should_eliminate_desc_if_it_is_just_whitespace() {
# Header\n\ # Header\n\
Body\"]\ Body\"]\
mod a { mod a {
#[legacy_exports]; }"); }");
assert doc.cratemod().mods()[0].desc() == None; assert doc.cratemod().mods()[0].desc() == None;
} }

View file

@ -46,7 +46,7 @@ fn test() {
let source = let source =
~"mod imod { } \ ~"mod imod { } \
extern mod inmod { extern mod inmod {
#[legacy_exports]; } \ } \
const iconst: int = 0; \ const iconst: int = 0; \
fn ifn() { } \ fn ifn() { } \
enum ienum { ivar } \ enum ienum { ivar } \

View file

@ -31,7 +31,7 @@ pub fn mk_pass() -> Pass {
fn should_trim_text() { fn should_trim_text() {
let doc = test::mk_doc(~"#[doc = \" desc \"] \ let doc = test::mk_doc(~"#[doc = \" desc \"] \
mod m { mod m {
#[legacy_exports]; }"); }");
assert doc.cratemod().mods()[0].desc() == Some(~"desc"); assert doc.cratemod().mods()[0].desc() == Some(~"desc");
} }