about summary refs log tree commit diff
path: root/src/test/stdtest
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-07-14 16:05:33 -0700
committerBrian Anderson <banderson@mozilla.com>2011-07-14 17:13:12 -0700
commit20e94de3925af29bd73a0f0f0b0706da72271115 (patch)
treefa40d1bcea157b4ddc596db6ffd2e4777c6a03a6 /src/test/stdtest
parent81acf69f9708a236ef78faa180575ae7b618fba9 (diff)
downloadrust-20e94de3925af29bd73a0f0f0b0706da72271115.tar.gz
rust-20e94de3925af29bd73a0f0f0b0706da72271115.zip
Add a flag to run ignored tests. Issue #428
Diffstat (limited to 'src/test/stdtest')
-rw-r--r--src/test/stdtest/test.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/test/stdtest/test.rs b/src/test/stdtest/test.rs
index 17f18a5151e..0079a94522b 100644
--- a/src/test/stdtest/test.rs
+++ b/src/test/stdtest/test.rs
@@ -1,4 +1,8 @@
 import std::test;
+import std::str;
+import std::option;
+import std::either;
+import std::ivec;
 
 #[test]
 fn do_not_run_ignored_tests() {
@@ -26,6 +30,42 @@ fn ignored_tests_result_in_ignored() {
     assert res == test::tr_ignored;
 }
 
+#[test]
+fn first_free_arg_should_be_a_filter() {
+    auto args = ~["progname", "filter"];
+    check ivec::is_not_empty(args);
+    auto opts = alt test::parse_opts(args) { either::left(?o) { o } };
+    assert str::eq("filter", option::get(opts.filter));
+}
+
+#[test]
+fn parse_ignored_flag() {
+    auto args = ~["progname", "filter", "--ignored"];
+    check ivec::is_not_empty(args);
+    auto opts = alt test::parse_opts(args) { either::left(?o) { o } };
+    assert opts.run_ignored;
+}
+
+#[test]
+fn filter_for_ignored_option() {
+    // When we run ignored tests the test filter should filter out all the
+    // unignored tests and flip the ignore flag on the rest to false
+
+    auto opts = rec(filter = option::none,
+                    run_ignored = true);
+    auto tests = ~[rec(name = "1",
+                       fn = fn() {},
+                       ignore = true),
+                   rec(name = "2",
+                       fn = fn() {},
+                       ignore = false)];
+    auto filtered = test::filter_tests(opts, tests);
+
+    assert ivec::len(filtered) == 1u;
+    assert filtered.(0).name == "1";
+    assert filtered.(0).ignore == false;
+}
+
 // Local Variables:
 // mode: rust;
 // fill-column: 78;