Skip to content

Commit 68152e6

Browse files
0c0w3brson
authored andcommitted
---
yaml --- r: 32540 b: refs/heads/dist-snap c: 98bd4a9 h: refs/heads/master v: v3
1 parent 5473665 commit 68152e6

File tree

3 files changed

+82
-4
lines changed

3 files changed

+82
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
10-
refs/heads/dist-snap: dc11e87b84cce79c68b9782cb7bd66decbf2b001
10+
refs/heads/dist-snap: 98bd4a992c8997126ea4a2d4c6c1960a80a06c09
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/dist-snap/src/compiletest/runtest.rs

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,9 @@ fn check_expected_errors(expected_errors: ~[errors::expected_error],
289289
was_expected = true;
290290
}
291291

292-
if !was_expected && (str::contains(line, ~"error") ||
293-
str::contains(line, ~"warning")) {
294-
fatal_procres(fmt!("unexpected error pattern '%s'!", line),
292+
if !was_expected && is_compiler_error_or_warning(line) {
293+
fatal_procres(fmt!("unexpected compiler error or warning: '%s'",
294+
line),
295295
procres);
296296
}
297297
}
@@ -305,6 +305,81 @@ fn check_expected_errors(expected_errors: ~[errors::expected_error],
305305
}
306306
}
307307

308+
fn is_compiler_error_or_warning(line: ~str) -> bool {
309+
let mut i = 0u;
310+
return
311+
scan_until_char(line, ':', &mut i) &&
312+
scan_char(line, ':', &mut i) &&
313+
scan_integer(line, &mut i) &&
314+
scan_char(line, ':', &mut i) &&
315+
scan_integer(line, &mut i) &&
316+
scan_char(line, ':', &mut i) &&
317+
scan_char(line, ' ', &mut i) &&
318+
scan_integer(line, &mut i) &&
319+
scan_char(line, ':', &mut i) &&
320+
scan_integer(line, &mut i) &&
321+
scan_char(line, ' ', &mut i) &&
322+
(scan_string(line, ~"error", &mut i) ||
323+
scan_string(line, ~"warning", &mut i));
324+
}
325+
326+
fn scan_until_char(haystack: ~str, needle: char, idx: &mut uint) -> bool {
327+
if *idx >= haystack.len() {
328+
return false;
329+
}
330+
let opt = str::find_char_from(haystack, needle, *idx);
331+
if opt.is_none() {
332+
return false;
333+
}
334+
*idx = opt.get();
335+
return true;
336+
}
337+
338+
fn scan_char(haystack: ~str, needle: char, idx: &mut uint) -> bool {
339+
if *idx >= haystack.len() {
340+
return false;
341+
}
342+
let {ch, next} = str::char_range_at(haystack, *idx);
343+
if ch != needle {
344+
return false;
345+
}
346+
*idx = next;
347+
return true;
348+
}
349+
350+
fn scan_integer(haystack: ~str, idx: &mut uint) -> bool {
351+
let mut i = *idx;
352+
while i < haystack.len() {
353+
let {ch, next} = str::char_range_at(haystack, i);
354+
if ch < '0' || '9' < ch {
355+
break;
356+
}
357+
i = next;
358+
}
359+
if i == *idx {
360+
return false;
361+
}
362+
*idx = i;
363+
return true;
364+
}
365+
366+
fn scan_string(haystack: ~str, needle: ~str, idx: &mut uint) -> bool {
367+
let mut haystack_i = *idx;
368+
let mut needle_i = 0u;
369+
while needle_i < needle.len() {
370+
if haystack_i >= haystack.len() {
371+
return false;
372+
}
373+
let {ch, next} = str::char_range_at(haystack, haystack_i);
374+
haystack_i = next;
375+
if !scan_char(needle, ch, &mut needle_i) {
376+
return false;
377+
}
378+
}
379+
*idx = haystack_i;
380+
return true;
381+
}
382+
308383
type procargs = {prog: ~str, args: ~[~str]};
309384

310385
type procres = {status: int, stdout: ~str, stderr: ~str, cmdline: ~str};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
log(error, x); //~ ERROR unresolved name: x
3+
}

0 commit comments

Comments
 (0)