Skip to content

Commit e500338

Browse files
committed
---
yaml --- r: 142753 b: refs/heads/try2 c: e14cd39 h: refs/heads/master i: 142751: f625fbb v: v3
1 parent 7293335 commit e500338

File tree

16 files changed

+1301
-1269
lines changed

16 files changed

+1301
-1269
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: f92b75ac06a86daac8d230285b605ec2ed97214b
8+
refs/heads/try2: e14cd392a4278223d858451a7b5cae327f76707c
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/compiletest/common.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub enum mode {
1515
mode_run_pass,
1616
mode_pretty,
1717
mode_debug_info,
18+
mode_codegen
1819
}
1920

2021
pub struct config {
@@ -27,6 +28,12 @@ pub struct config {
2728
// The rustc executable
2829
rustc_path: Path,
2930

31+
// The clang executable
32+
clang_path: Option<Path>,
33+
34+
// The llvm binaries path
35+
llvm_bin_path: Option<Path>,
36+
3037
// The directory containing the tests to run
3138
src_base: Path,
3239

branches/try2/src/compiletest/compiletest.rs

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ extern mod extra;
1919
use std::os;
2020

2121
use extra::getopts;
22+
use extra::getopts::groups::{optopt, optflag, reqopt};
2223
use extra::test;
2324

2425
use common::config;
@@ -27,6 +28,7 @@ use common::mode_run_fail;
2728
use common::mode_compile_fail;
2829
use common::mode_pretty;
2930
use common::mode_debug_info;
31+
use common::mode_codegen;
3032
use common::mode;
3133
use util::logv;
3234

@@ -45,31 +47,54 @@ pub fn main() {
4547
}
4648

4749
pub fn parse_config(args: ~[~str]) -> config {
48-
let opts =
49-
~[getopts::reqopt("compile-lib-path"),
50-
getopts::reqopt("run-lib-path"),
51-
getopts::reqopt("rustc-path"), getopts::reqopt("src-base"),
52-
getopts::reqopt("build-base"), getopts::reqopt("aux-base"),
53-
getopts::reqopt("stage-id"),
54-
getopts::reqopt("mode"), getopts::optflag("ignored"),
55-
getopts::optopt("runtool"), getopts::optopt("rustcflags"),
56-
getopts::optflag("verbose"),
57-
getopts::optopt("logfile"),
58-
getopts::optflag("jit"),
59-
getopts::optflag("newrt"),
60-
getopts::optopt("target"),
61-
getopts::optopt("adb-path"),
62-
getopts::optopt("adb-test-dir")
50+
51+
let groups : ~[getopts::groups::OptGroup] =
52+
~[reqopt("", "compile-lib-path", "path to host shared libraries", "PATH"),
53+
reqopt("", "run-lib-path", "path to target shared libraries", "PATH"),
54+
reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH"),
55+
optopt("", "clang-path", "path to executable for codegen tests", "PATH"),
56+
optopt("", "llvm-bin-path", "path to directory holding llvm binaries", "DIR"),
57+
reqopt("", "src-base", "directory to scan for test files", "PATH"),
58+
reqopt("", "build-base", "directory to deposit test outputs", "PATH"),
59+
reqopt("", "aux-base", "directory to find auxiliary test files", "PATH"),
60+
reqopt("", "stage-id", "the target-stage identifier", "stageN-TARGET"),
61+
reqopt("", "mode", "which sort of compile tests to run",
62+
"(compile-fail|run-fail|run-pass|pretty|debug-info)"),
63+
optflag("", "ignored", "run tests marked as ignored / xfailed"),
64+
optopt("", "runtool", "supervisor program to run tests under \
65+
(eg. emulator, valgrind)", "PROGRAM"),
66+
optopt("", "rustcflags", "flags to pass to rustc", "FLAGS"),
67+
optflag("", "verbose", "run tests verbosely, showing all output"),
68+
optopt("", "logfile", "file to log test execution to", "FILE"),
69+
optflag("", "jit", "run tests under the JIT"),
70+
optflag("", "newrt", "run tests on the new runtime / scheduler"),
71+
optopt("", "target", "the target to build for", "TARGET"),
72+
optopt("", "adb-path", "path to the android debugger", "PATH"),
73+
optopt("", "adb-test-dir", "path to tests for the android debugger", "PATH"),
74+
optflag("h", "help", "show this message"),
6375
];
6476

6577
assert!(!args.is_empty());
78+
let argv0 = copy args[0];
6679
let args_ = args.tail();
80+
if args[1] == ~"-h" || args[1] == ~"--help" {
81+
let message = fmt!("Usage: %s [OPTIONS] [TESTNAME...]", argv0);
82+
io::println(getopts::groups::usage(message, groups));
83+
fail!()
84+
}
85+
6786
let matches =
68-
&match getopts::getopts(args_, opts) {
87+
&match getopts::groups::getopts(args_, groups) {
6988
Ok(m) => m,
7089
Err(f) => fail!(getopts::fail_str(f))
7190
};
7291

92+
if getopts::opt_present(matches, "h") || getopts::opt_present(matches, "help") {
93+
let message = fmt!("Usage: %s [OPTIONS] [TESTNAME...]", argv0);
94+
io::println(getopts::groups::usage(message, groups));
95+
fail!()
96+
}
97+
7398
fn opt_path(m: &getopts::Matches, nm: &str) -> Path {
7499
Path(getopts::opt_str(m, nm))
75100
}
@@ -78,6 +103,8 @@ pub fn parse_config(args: ~[~str]) -> config {
78103
compile_lib_path: getopts::opt_str(matches, "compile-lib-path"),
79104
run_lib_path: getopts::opt_str(matches, "run-lib-path"),
80105
rustc_path: opt_path(matches, "rustc-path"),
106+
clang_path: getopts::opt_maybe_str(matches, "clang-path").map(|s| Path(*s)),
107+
llvm_bin_path: getopts::opt_maybe_str(matches, "llvm-bin-path").map(|s| Path(*s)),
81108
src_base: opt_path(matches, "src-base"),
82109
build_base: opt_path(matches, "build-base"),
83110
aux_base: opt_path(matches, "aux-base"),
@@ -159,6 +186,7 @@ pub fn str_mode(s: ~str) -> mode {
159186
~"run-pass" => mode_run_pass,
160187
~"pretty" => mode_pretty,
161188
~"debug-info" => mode_debug_info,
189+
~"codegen" => mode_codegen,
162190
_ => fail!("invalid mode")
163191
}
164192
}
@@ -170,6 +198,7 @@ pub fn mode_str(mode: mode) -> ~str {
170198
mode_run_pass => ~"run-pass",
171199
mode_pretty => ~"pretty",
172200
mode_debug_info => ~"debug-info",
201+
mode_codegen => ~"codegen",
173202
}
174203
}
175204

branches/try2/src/compiletest/runtest.rs

Lines changed: 117 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ pub fn run(config: config, testfile: ~str) {
3939
mode_run_fail => run_rfail_test(&config, &props, &testfile),
4040
mode_run_pass => run_rpass_test(&config, &props, &testfile),
4141
mode_pretty => run_pretty_test(&config, &props, &testfile),
42-
mode_debug_info => run_debuginfo_test(&config, &props, &testfile)
42+
mode_debug_info => run_debuginfo_test(&config, &props, &testfile),
43+
mode_codegen => run_codegen_test(&config, &props, &testfile)
4344
}
4445
}
4546

@@ -835,3 +836,118 @@ fn _arm_push_aux_shared_library(config: &config, testfile: &Path) {
835836
}
836837
}
837838
}
839+
840+
// codegen tests (vs. clang)
841+
842+
fn make_o_name(config: &config, testfile: &Path) -> Path {
843+
output_base_name(config, testfile).with_filetype("o")
844+
}
845+
846+
fn append_suffix_to_stem(p: &Path, suffix: &str) -> Path {
847+
if suffix.len() == 0 {
848+
copy *p
849+
} else {
850+
let stem = p.filestem().get();
851+
p.with_filestem(stem + "-" + suffix)
852+
}
853+
}
854+
855+
fn compile_test_and_save_bitcode(config: &config, props: &TestProps,
856+
testfile: &Path) -> ProcRes {
857+
let link_args = ~[~"-L", aux_output_dir_name(config, testfile).to_str()];
858+
let llvm_args = ~[~"-c", ~"--lib", ~"--save-temps"];
859+
let args = make_compile_args(config, props,
860+
link_args + llvm_args,
861+
make_o_name, testfile);
862+
compose_and_run_compiler(config, props, testfile, args, None)
863+
}
864+
865+
fn compile_cc_with_clang_and_save_bitcode(config: &config, _props: &TestProps,
866+
testfile: &Path) -> ProcRes {
867+
let bitcodefile = output_base_name(config, testfile).with_filetype("bc");
868+
let bitcodefile = append_suffix_to_stem(&bitcodefile, "clang");
869+
let ProcArgs = ProcArgs {
870+
prog: config.clang_path.get_ref().to_str(),
871+
args: ~[~"-c",
872+
~"-emit-llvm",
873+
~"-o", bitcodefile.to_str(),
874+
testfile.with_filetype("cc").to_str() ]
875+
};
876+
compose_and_run(config, testfile, ProcArgs, ~[], "", None)
877+
}
878+
879+
fn extract_function_from_bitcode(config: &config, _props: &TestProps,
880+
fname: &str, testfile: &Path,
881+
suffix: &str) -> ProcRes {
882+
let bitcodefile = output_base_name(config, testfile).with_filetype("bc");
883+
let bitcodefile = append_suffix_to_stem(&bitcodefile, suffix);
884+
let extracted_bc = append_suffix_to_stem(&bitcodefile, "extract");
885+
let ProcArgs = ProcArgs {
886+
prog: config.llvm_bin_path.get_ref().push("llvm-extract").to_str(),
887+
args: ~[~"-func=" + fname,
888+
~"-o=" + extracted_bc.to_str(),
889+
bitcodefile.to_str() ]
890+
};
891+
compose_and_run(config, testfile, ProcArgs, ~[], "", None)
892+
}
893+
894+
fn disassemble_extract(config: &config, _props: &TestProps,
895+
testfile: &Path, suffix: &str) -> ProcRes {
896+
let bitcodefile = output_base_name(config, testfile).with_filetype("bc");
897+
let bitcodefile = append_suffix_to_stem(&bitcodefile, suffix);
898+
let extracted_bc = append_suffix_to_stem(&bitcodefile, "extract");
899+
let extracted_ll = extracted_bc.with_filetype("ll");
900+
let ProcArgs = ProcArgs {
901+
prog: config.llvm_bin_path.get_ref().push("llvm-dis").to_str(),
902+
args: ~[~"-o=" + extracted_ll.to_str(),
903+
extracted_bc.to_str() ]
904+
};
905+
compose_and_run(config, testfile, ProcArgs, ~[], "", None)
906+
}
907+
908+
909+
fn run_codegen_test(config: &config, props: &TestProps, testfile: &Path) {
910+
911+
if config.llvm_bin_path.is_none() {
912+
fatal(~"missing --llvm-bin-path");
913+
}
914+
915+
if config.clang_path.is_none() {
916+
fatal(~"missing --clang-path");
917+
}
918+
919+
let mut ProcRes = compile_test_and_save_bitcode(config, props, testfile);
920+
if ProcRes.status != 0 {
921+
fatal_ProcRes(~"compilation failed!", &ProcRes);
922+
}
923+
924+
ProcRes = extract_function_from_bitcode(config, props, "test", testfile, "");
925+
if ProcRes.status != 0 {
926+
fatal_ProcRes(~"extracting 'test' function failed", &ProcRes);
927+
}
928+
929+
ProcRes = disassemble_extract(config, props, testfile, "");
930+
if ProcRes.status != 0 {
931+
fatal_ProcRes(~"disassembling extract failed", &ProcRes);
932+
}
933+
934+
935+
let mut ProcRes = compile_cc_with_clang_and_save_bitcode(config, props, testfile);
936+
if ProcRes.status != 0 {
937+
fatal_ProcRes(~"compilation failed!", &ProcRes);
938+
}
939+
940+
ProcRes = extract_function_from_bitcode(config, props, "test", testfile, "clang");
941+
if ProcRes.status != 0 {
942+
fatal_ProcRes(~"extracting 'test' function failed", &ProcRes);
943+
}
944+
945+
ProcRes = disassemble_extract(config, props, testfile, "clang");
946+
if ProcRes.status != 0 {
947+
fatal_ProcRes(~"disassembling extract failed", &ProcRes);
948+
}
949+
950+
951+
952+
}
953+

branches/try2/src/etc/vim/ftplugin/rust.vim

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
11
" Vim syntax file
22
" Language: Rust
33
" Maintainer: Chris Morgan <[email protected]>
4-
" Last Change: 2013 Jul 10
4+
" Last Change: 2013 Jul 6
55

66
if exists("b:did_ftplugin")
77
finish
88
endif
99
let b:did_ftplugin = 1
1010

11-
" The rust source code at present seems to typically omit a leader on /*!
12-
" comments, so we'll use that as our default, but make it easy to switch.
13-
" This does not affect indentation at all (I tested it with and without
14-
" leader), merely whether a leader is inserted by default or not.
15-
if exists("g:rust_bang_comment_leader") && g:rust_bang_comment_leader == 1
16-
" Why is the `,s0:/*,mb:\ ,ex:*/` there, you ask? I don't understand why,
17-
" but without it, */ gets indented one space even if there were no
18-
" leaders. I'm fairly sure that's a Vim bug.
19-
setlocal comments=s1:/*,mb:*,ex:*/,s0:/*,mb:\ ,ex:*/,:///,://!,://
20-
else
21-
setlocal comments=s0:/*!,m:\ ,ex:*/,s1:/*,mb:*,ex:*/,:///,://!,://
22-
endif
11+
setlocal comments=s1:/*,mb:*,ex:*/,:///,://!,://
2312
setlocal commentstring=//%s
2413
setlocal formatoptions-=t formatoptions+=croqnlj
2514

branches/try2/src/etc/vim/indent/rust.vim

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ endif
1010
let b:did_indent = 1
1111

1212
setlocal cindent
13-
setlocal cinoptions=L0,(0,Ws,JN,j1
13+
setlocal cinoptions=L0,(0,Ws,JN
1414
setlocal cinkeys=0{,0},!^F,o,O,0[,0]
1515
" Don't think cinwords will actually do anything at all... never mind
1616
setlocal cinwords=do,for,if,else,while,loop,impl,mod,unsafe,trait,struct,enum,fn,extern
@@ -66,23 +66,12 @@ function GetRustIndent(lnum)
6666
" Starting assumption: cindent (called at the end) will do it right
6767
" normally. We just want to fix up a few cases.
6868

69-
let line = getline(a:lnum)
70-
7169
if has('syntax_items')
72-
let synname = synIDattr(synID(a:lnum, 1, 1), "name")
73-
if synname == "rustString"
70+
if synIDattr(synID(a:lnum, 1, 1), "name") == "rustString"
7471
" If the start of the line is in a string, don't change the indent
7572
return -1
76-
elseif synname =~ "\\(Comment\\|Todo\\)"
77-
\ && line !~ "^\\s*/\\*" " not /* opening line
78-
if synname =~ "CommentML" " multi-line
79-
if line !~ "^\\s*\\*" && getline(a:lnum - 1) =~ "^\\s*/\\*"
80-
" This is (hopefully) the line after a /*, and it has no
81-
" leader, so the correct indentation is that of the
82-
" previous line.
83-
return GetRustIndent(a:lnum - 1)
84-
endif
85-
endif
73+
elseif synIDattr(synID(a:lnum, 1, 1), "name") =~ "\\(Comment\\|Todo\\)"
74+
\ && getline(a:lnum) !~ "^\\s*/\\*"
8675
" If it's in a comment, let cindent take care of it now. This is
8776
" for cases like "/*" where the next line should start " * ", not
8877
" "* " as the code below would otherwise cause for module scope
@@ -125,6 +114,7 @@ function GetRustIndent(lnum)
125114
" start with these two main cases (square brackets and not returning to
126115
" column zero)
127116

117+
let line = getline(a:lnum)
128118
call cursor(a:lnum, 1)
129119
if searchpair('{\|(', '', '}\|)', 'nbW') == 0
130120
if searchpair('\[', '', '\]', 'nbW') == 0

branches/try2/src/etc/vim/syntax/rust.vim

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ syn match rustFloat display "\<[0-9][0-9_]*\.[0-9_]\+\%([eE][+-]\=[0-9
117117
syn match rustLifetime display "\'\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*"
118118
syn match rustCharacter "'\([^'\\]\|\\\(['nrt\\\"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'"
119119

120-
syn region rustCommentML start="/\*" end="\*/" contains=rustTodo
120+
syn region rustComment start="/\*" end="\*/" contains=rustTodo
121121
syn region rustComment start="//" skip="\\$" end="$" contains=rustTodo keepend
122-
syn region rustCommentMLDoc start="/\*\%(!\|\*/\@!\)" end="\*/" contains=rustTodo
122+
syn region rustCommentDoc start="/\*\%(!\|\*/\@!\)" end="\*/" contains=rustTodo
123123
syn region rustCommentDoc start="//[/!]" skip="\\$" end="$" contains=rustTodo keepend
124124

125125
syn keyword rustTodo contained TODO FIXME XXX NB NOTE
@@ -151,9 +151,7 @@ hi def link rustModPath Include
151151
hi def link rustModPathSep Delimiter
152152
hi def link rustFuncName Function
153153
hi def link rustFuncCall Function
154-
hi def link rustCommentMLDoc rustCommentDoc
155154
hi def link rustCommentDoc SpecialComment
156-
hi def link rustCommentML rustComment
157155
hi def link rustComment Comment
158156
hi def link rustAssert PreCondit
159157
hi def link rustFail PreCondit

0 commit comments

Comments
 (0)