Skip to content

Commit 8e96d1e

Browse files
committed
---
yaml --- r: 182655 b: refs/heads/beta c: 000dc07 h: refs/heads/master i: 182653: 2303780 182651: 1d77b8c 182647: 58e680b 182639: 0ec0274 182623: abe870e 182591: b0d93b2 182527: d6f3493 v: v3
1 parent 8ace348 commit 8e96d1e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+5279
-5073
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3131
refs/heads/issue-18208-method-dispatch-3-quick-reject: 2009f85b9f99dedcec4404418eda9ddba90258a2
3232
refs/heads/batch: b7fd822592a4fb577552d93010c4a4e14f314346
3333
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
34-
refs/heads/beta: 43046becce78147fa43808626bbb48569086b6a5
34+
refs/heads/beta: 000dc07f71baafc31da74e392ad5530fb6de9757
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
3737
refs/heads/tmp: eb836bf767aa1d8d4cba488a9091cde3c0ab4b2f

branches/beta/configure

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,8 +645,6 @@ probe CFG_ISCC iscc
645645
probe CFG_JAVAC javac
646646
probe CFG_ANTLR4 antlr4
647647
probe CFG_GRUN grun
648-
probe CFG_FLEX flex
649-
probe CFG_BISON bison
650648
probe CFG_PANDOC pandoc
651649
probe CFG_PDFLATEX pdflatex
652650
probe CFG_XELATEX xelatex

branches/beta/mk/crates.mk

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
TARGET_CRATES := libc std flate arena term \
5353
serialize getopts collections test rand \
54-
log graphviz core rbml alloc \
54+
log regex graphviz core rbml alloc \
5555
unicode rustc_bitflags
5656
RUSTC_CRATES := rustc rustc_typeck rustc_borrowck rustc_resolve rustc_driver \
5757
rustc_trans rustc_back rustc_llvm rustc_privacy
@@ -95,15 +95,16 @@ DEPS_term := std log
9595
DEPS_getopts := std
9696
DEPS_collections := core alloc unicode
9797
DEPS_num := std
98-
DEPS_test := std getopts serialize rbml term native:rust_test_helpers
98+
DEPS_test := std getopts serialize rbml term regex native:rust_test_helpers
9999
DEPS_rand := core
100-
DEPS_log := std
100+
DEPS_log := std regex
101+
DEPS_regex := std
101102
DEPS_fmt_macros = std
102103

103104
TOOL_DEPS_compiletest := test getopts
104105
TOOL_DEPS_rustdoc := rustdoc
105106
TOOL_DEPS_rustc := rustc_driver
106-
TOOL_DEPS_rustbook := std rustdoc
107+
TOOL_DEPS_rustbook := std regex rustdoc
107108
TOOL_SOURCE_compiletest := $(S)src/compiletest/compiletest.rs
108109
TOOL_SOURCE_rustdoc := $(S)src/driver/driver.rs
109110
TOOL_SOURCE_rustc := $(S)src/driver/driver.rs
@@ -129,8 +130,9 @@ DOC_CRATES := $(filter-out rustc, \
129130
$(filter-out rustc_driver, \
130131
$(filter-out rustc_privacy, \
131132
$(filter-out log, \
133+
$(filter-out regex, \
132134
$(filter-out getopts, \
133-
$(filter-out syntax, $(CRATES)))))))))))
135+
$(filter-out syntax, $(CRATES))))))))))))
134136
COMPILER_DOC_CRATES := rustc rustc_trans rustc_borrowck rustc_resolve \
135137
rustc_typeck rustc_driver syntax rustc_privacy
136138

branches/beta/mk/grammar.mk

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ B = $(CFG_BUILD_DIR)/$(CFG_BUILD)/stage2/
1414
L = $(B)lib/rustlib/$(CFG_BUILD)/lib
1515
LD = $(CFG_BUILD)/stage2/lib/rustlib/$(CFG_BUILD)/lib/
1616
RUSTC = $(STAGE2_T_$(CFG_BUILD)_H_$(CFG_BUILD))
17-
ifeq ($(CFG_OSTYPE),apple-darwin)
18-
FLEX_LDFLAGS=-ll
19-
else
20-
FLEX_LDFLAGS=-lfl
21-
endif
2217

2318
# Run the reference lexer against libsyntax and compare the tokens and spans.
2419
# If "// ignore-lexer-test" is present in the file, it will be ignored.
@@ -72,46 +67,3 @@ $(info cfg: javac not available, skipping lexer test...)
7267
check-lexer:
7368

7469
endif
75-
76-
$(BG)lex.yy.c: $(SG)lexer.l $(BG)
77-
@$(call E, flex: $@)
78-
$(Q)$(CFG_FLEX) -o $@ $<
79-
80-
$(BG)lexer-lalr.o: $(BG)lex.yy.c $(BG)parser-lalr.tab.h
81-
@$(call E, cc: $@)
82-
$(Q)$(CFG_CC) -include $(BG)parser-lalr.tab.h -c -o $@ $<
83-
84-
$(BG)parser-lalr.tab.c $(BG)parser-lalr.tab.h: $(SG)parser-lalr.y
85-
@$(call E, bison: $@)
86-
$(Q)$(CFG_BISON) $< --output=$(BG)parser-lalr.tab.c --defines=$(BG)parser-lalr.tab.h \
87-
--name-prefix=rs --warnings=error=all
88-
89-
$(BG)parser-lalr.o: $(BG)parser-lalr.tab.c
90-
@$(call E, cc: $@)
91-
$(Q)$(CFG_CC) -c -o $@ $<
92-
93-
$(BG)parser-lalr-main.o: $(SG)parser-lalr-main.c
94-
@$(call E, cc: $@)
95-
$(Q)$(CFG_CC) -std=c99 -c -o $@ $<
96-
97-
$(BG)parser-lalr: $(BG)parser-lalr.o $(BG)parser-lalr-main.o $(BG)lexer-lalr.o
98-
@$(call E, cc: $@)
99-
$(Q)$(CFG_CC) -o $@ $^ $(FLEX_LDFLAGS)
100-
101-
102-
ifdef CFG_FLEX
103-
ifdef CFG_BISON
104-
check-grammar: $(BG) $(BG)parser-lalr
105-
$(info Verifying grammar ...)
106-
$(SG)testparser.py -p $(BG)parser-lalr -s $(S)src
107-
108-
else
109-
$(info cfg: bison not available, skipping parser test...)
110-
check-grammar:
111-
112-
endif
113-
else
114-
$(info cfg: flex not available, skipping parser test...)
115-
check-grammar:
116-
117-
endif

branches/beta/src/compiletest/common.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub use self::Mode::*;
1111

1212
use std::fmt;
1313
use std::str::FromStr;
14+
use regex::Regex;
1415

1516
#[derive(Clone, PartialEq, Debug)]
1617
pub enum Mode {
@@ -100,7 +101,10 @@ pub struct Config {
100101
pub run_ignored: bool,
101102

102103
// Only run tests that match this filter
103-
pub filter: Option<String>,
104+
pub filter: Option<Regex>,
105+
106+
// Precompiled regex for finding expected errors in cfail
107+
pub cfail_regex: Regex,
104108

105109
// Write out a parseable log of tests that were run
106110
pub logfile: Option<Path>,

branches/beta/src/compiletest/compiletest.rs

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ extern crate getopts;
2222

2323
#[macro_use]
2424
extern crate log;
25+
extern crate regex;
2526

2627
use std::os;
2728
use std::io;
@@ -32,6 +33,7 @@ use getopts::{optopt, optflag, reqopt};
3233
use common::Config;
3334
use common::{Pretty, DebugInfoGdb, DebugInfoLldb, Codegen};
3435
use util::logv;
36+
use regex::Regex;
3537

3638
pub mod procsrv;
3739
pub mod util;
@@ -114,7 +116,14 @@ pub fn parse_config(args: Vec<String> ) -> Config {
114116
}
115117

116118
let filter = if !matches.free.is_empty() {
117-
Some(matches.free[0].clone())
119+
let s = matches.free[0].as_slice();
120+
match regex::Regex::new(s) {
121+
Ok(re) => Some(re),
122+
Err(e) => {
123+
println!("failed to parse filter /{}/: {:?}", s, e);
124+
panic!()
125+
}
126+
}
118127
} else {
119128
None
120129
};
@@ -136,6 +145,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
136145
.as_slice()).expect("invalid mode"),
137146
run_ignored: matches.opt_present("ignored"),
138147
filter: filter,
148+
cfail_regex: Regex::new(errors::EXPECTED_PATTERN).unwrap(),
139149
logfile: matches.opt_str("logfile").map(|s| Path::new(s)),
140150
runtool: matches.opt_str("runtool"),
141151
host_rustcflags: matches.opt_str("host-rustcflags"),
@@ -364,24 +374,18 @@ fn extract_gdb_version(full_version_line: Option<String>) -> Option<String> {
364374
if full_version_line.as_slice().trim().len() > 0 => {
365375
let full_version_line = full_version_line.as_slice().trim();
366376

367-
// used to be a regex "(^|[^0-9])([0-9]\.[0-9])([^0-9]|$)"
368-
for (pos, c) in full_version_line.char_indices() {
369-
if !c.is_digit(10) { continue }
370-
if pos + 2 >= full_version_line.len() { continue }
371-
if full_version_line.char_at(pos + 1) != '.' { continue }
372-
if !full_version_line.char_at(pos + 2).is_digit(10) { continue }
373-
if pos > 0 && full_version_line.char_at_reverse(pos).is_digit(10) {
374-
continue
377+
let re = Regex::new(r"(^|[^0-9])([0-9]\.[0-9])([^0-9]|$)").unwrap();
378+
379+
match re.captures(full_version_line) {
380+
Some(captures) => {
381+
Some(captures.at(2).unwrap_or("").to_string())
375382
}
376-
if pos + 3 < full_version_line.len() &&
377-
full_version_line.char_at(pos + 3).is_digit(10) {
378-
continue
383+
None => {
384+
println!("Could not extract GDB version from line '{}'",
385+
full_version_line);
386+
None
379387
}
380-
return Some(full_version_line[pos..pos+3].to_string());
381388
}
382-
println!("Could not extract GDB version from line '{}'",
383-
full_version_line);
384-
None
385389
},
386390
_ => None
387391
}
@@ -404,26 +408,18 @@ fn extract_lldb_version(full_version_line: Option<String>) -> Option<String> {
404408
if full_version_line.as_slice().trim().len() > 0 => {
405409
let full_version_line = full_version_line.as_slice().trim();
406410

407-
for (pos, l) in full_version_line.char_indices() {
408-
if l != 'l' && l != 'L' { continue }
409-
if pos + 5 >= full_version_line.len() { continue }
410-
let l = full_version_line.char_at(pos + 1);
411-
if l != 'l' && l != 'L' { continue }
412-
let d = full_version_line.char_at(pos + 2);
413-
if d != 'd' && d != 'D' { continue }
414-
let b = full_version_line.char_at(pos + 3);
415-
if b != 'b' && b != 'B' { continue }
416-
let dash = full_version_line.char_at(pos + 4);
417-
if dash != '-' { continue }
418-
419-
let vers = full_version_line[pos + 5..].chars().take_while(|c| {
420-
c.is_digit(10)
421-
}).collect::<String>();
422-
if vers.len() > 0 { return Some(vers) }
411+
let re = Regex::new(r"[Ll][Ll][Dd][Bb]-([0-9]+)").unwrap();
412+
413+
match re.captures(full_version_line) {
414+
Some(captures) => {
415+
Some(captures.at(1).unwrap_or("").to_string())
416+
}
417+
None => {
418+
println!("Could not extract LLDB version from line '{}'",
419+
full_version_line);
420+
None
421+
}
423422
}
424-
println!("Could not extract LLDB version from line '{}'",
425-
full_version_line);
426-
None
427423
},
428424
_ => None
429425
}

branches/beta/src/compiletest/errors.rs

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,32 @@
99
// except according to those terms.
1010
use self::WhichLine::*;
1111

12+
use std::ascii::AsciiExt;
1213
use std::io::{BufferedReader, File};
14+
use regex::Regex;
1315

1416
pub struct ExpectedError {
1517
pub line: uint,
1618
pub kind: String,
1719
pub msg: String,
1820
}
1921

20-
#[derive(PartialEq, Show)]
21-
enum WhichLine { ThisLine, FollowPrevious(uint), AdjustBackward(uint) }
22-
2322
/// Looks for either "//~| KIND MESSAGE" or "//~^^... KIND MESSAGE"
2423
/// The former is a "follow" that inherits its target from the preceding line;
2524
/// the latter is an "adjusts" that goes that many lines up.
2625
///
2726
/// Goal is to enable tests both like: //~^^^ ERROR go up three
2827
/// and also //~^ ERROR message one for the preceding line, and
2928
/// //~| ERROR message two for that same line.
29+
30+
pub static EXPECTED_PATTERN : &'static str =
31+
r"//~(?P<follow>\|)?(?P<adjusts>\^*)\s*(?P<kind>\S*)\s*(?P<msg>.*)";
32+
33+
#[derive(PartialEq, Show)]
34+
enum WhichLine { ThisLine, FollowPrevious(uint), AdjustBackward(uint) }
35+
3036
// Load any test directives embedded in the file
31-
pub fn load_errors(testfile: &Path) -> Vec<ExpectedError> {
37+
pub fn load_errors(re: &Regex, testfile: &Path) -> Vec<ExpectedError> {
3238
let mut rdr = BufferedReader::new(File::open(testfile).unwrap());
3339

3440
// `last_nonfollow_error` tracks the most recently seen
@@ -44,7 +50,7 @@ pub fn load_errors(testfile: &Path) -> Vec<ExpectedError> {
4450
rdr.lines().enumerate().filter_map(|(line_no, ln)| {
4551
parse_expected(last_nonfollow_error,
4652
line_no + 1,
47-
ln.unwrap().as_slice())
53+
ln.unwrap().as_slice(), re)
4854
.map(|(which, error)| {
4955
match which {
5056
FollowPrevious(_) => {}
@@ -57,39 +63,30 @@ pub fn load_errors(testfile: &Path) -> Vec<ExpectedError> {
5763

5864
fn parse_expected(last_nonfollow_error: Option<uint>,
5965
line_num: uint,
60-
line: &str) -> Option<(WhichLine, ExpectedError)> {
61-
let start = match line.find_str("//~") { Some(i) => i, None => return None };
62-
let (follow, adjusts) = if line.char_at(start + 3) == '|' {
63-
(true, 0)
64-
} else {
65-
(false, line[start + 3..].chars().take_while(|c| *c == '^').count())
66-
};
67-
let kind_start = start + 3 + adjusts + (follow as usize);
68-
let letters = line[kind_start..].chars();
69-
let kind = letters.skip_while(|c| c.is_whitespace())
70-
.take_while(|c| !c.is_whitespace())
71-
.map(|c| c.to_lowercase())
72-
.collect::<String>();
73-
let letters = line[kind_start..].chars();
74-
let msg = letters.skip_while(|c| c.is_whitespace())
75-
.skip_while(|c| !c.is_whitespace())
76-
.collect::<String>().trim().to_string();
66+
line: &str,
67+
re: &Regex) -> Option<(WhichLine, ExpectedError)> {
68+
re.captures(line).and_then(|caps| {
69+
let adjusts = caps.name("adjusts").unwrap_or("").len();
70+
let kind = caps.name("kind").unwrap_or("").to_ascii_lowercase();
71+
let msg = caps.name("msg").unwrap_or("").trim().to_string();
72+
let follow = caps.name("follow").unwrap_or("").len() > 0;
7773

78-
let (which, line) = if follow {
79-
assert!(adjusts == 0, "use either //~| or //~^, not both.");
80-
let line = last_nonfollow_error.unwrap_or_else(|| {
81-
panic!("encountered //~| without preceding //~^ line.")
82-
});
83-
(FollowPrevious(line), line)
84-
} else {
85-
let which =
86-
if adjusts > 0 { AdjustBackward(adjusts) } else { ThisLine };
87-
let line = line_num - adjusts;
88-
(which, line)
89-
};
74+
let (which, line) = if follow {
75+
assert!(adjusts == 0, "use either //~| or //~^, not both.");
76+
let line = last_nonfollow_error.unwrap_or_else(|| {
77+
panic!("encountered //~| without preceding //~^ line.")
78+
});
79+
(FollowPrevious(line), line)
80+
} else {
81+
let which =
82+
if adjusts > 0 { AdjustBackward(adjusts) } else { ThisLine };
83+
let line = line_num - adjusts;
84+
(which, line)
85+
};
9086

91-
debug!("line={} which={:?} kind={:?} msg={:?}", line_num, which, kind, msg);
92-
Some((which, ExpectedError { line: line,
93-
kind: kind,
94-
msg: msg, }))
87+
debug!("line={} which={:?} kind={:?} msg={:?}", line_num, which, kind, msg);
88+
Some((which, ExpectedError { line: line,
89+
kind: kind,
90+
msg: msg, }))
91+
})
9592
}

branches/beta/src/compiletest/runtest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ fn run_cfail_test(config: &Config, props: &TestProps, testfile: &Path) {
9999
}
100100

101101
let output_to_check = get_output(props, &proc_res);
102-
let expected_errors = errors::load_errors(testfile);
102+
let expected_errors = errors::load_errors(&config.cfail_regex, testfile);
103103
if !expected_errors.is_empty() {
104104
if !props.error_patterns.is_empty() {
105105
fatal("both error pattern and expected errors specified");

0 commit comments

Comments
 (0)