CcTest* CcTest::last_ = NULL;
-CcTest::CcTest(TestFunction* callback, const char* file, const char* name)
+CcTest::CcTest(TestFunction* callback, const char* file,
+ const char* name, bool enabled)
: callback_(callback), name_(name), prev_(last_) {
// Find the base name of this test (const_cast required on Windows).
char *basename = strrchr(const_cast<char *>(file), '/');
if (extension) *extension = 0;
// Install this test in the list of tests
file_ = basename;
+ enabled_ = enabled;
prev_ = last_;
last_ = this;
}
}
-static int RunMatchingTests(CcTest* current, char* file_or_name) {
- if (current == NULL) return 0;
- int run_count = 0;
- if (strcmp(current->file(), file_or_name) == 0
- || strcmp(current->name(), file_or_name) == 0) {
- current->Run();
- run_count++;
- }
- return run_count + RunMatchingTests(current->prev(), file_or_name);
-}
-
-
-static int RunMatchingTests(CcTest* current, char* file, char* name) {
- if (current == NULL) return 0;
- int run_count = 0;
- if (strcmp(current->file(), file) == 0
- && strcmp(current->name(), name) == 0) {
- current->Run();
- run_count++;
- }
- return run_count + RunMatchingTests(current->prev(), file, name);
-}
-
-
int main(int argc, char* argv[]) {
v8::internal::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
int tests_run = 0;
if (strcmp(arg, "--list") == 0) {
PrintTestList(CcTest::last());
print_run_count = false;
+
} else {
char* arg_copy = strdup(arg);
char* testname = strchr(arg_copy, '/');
// Split the string in two by nulling the slash and then run
// exact matches.
*testname = 0;
- tests_run += RunMatchingTests(CcTest::last(), arg_copy, testname + 1);
+ char* file = arg_copy;
+ char* name = testname + 1;
+ CcTest* test = CcTest::last();
+ while (test != NULL) {
+ if (test->enabled()
+ && strcmp(test->file(), file) == 0
+ && strcmp(test->name(), name) == 0) {
+ test->Run();
+ tests_run++;
+ }
+ test = test->prev();
+ }
+
} else {
// Run all tests with the specified file or test name.
- tests_run += RunMatchingTests(CcTest::last(), arg_copy);
+ char* file_or_name = arg_copy;
+ CcTest* test = CcTest::last();
+ while (test != NULL) {
+ if (test->enabled()
+ && (strcmp(test->file(), file_or_name) == 0
+ || strcmp(test->name(), file_or_name) == 0)) {
+ test->Run();
+ tests_run++;
+ }
+ test = test->prev();
+ }
}
free(arg_copy);
}
#ifndef TEST
#define TEST(Name) \
static void Test##Name(); \
- CcTest register_test_##Name(Test##Name, __FILE__, #Name); \
+ CcTest register_test_##Name(Test##Name, __FILE__, #Name, true); \
+ static void Test##Name()
+#endif
+
+#ifndef DISABLED_TEST
+#define DISABLED_TEST(Name) \
+ static void Test##Name(); \
+ CcTest register_test_##Name(Test##Name, __FILE__, #Name, false); \
static void Test##Name()
#endif
class CcTest {
public:
typedef void (TestFunction)();
- CcTest(TestFunction* callback, const char* file, const char* name);
+ CcTest(TestFunction* callback, const char* file, const char* name,
+ bool enabled);
void Run() { callback_(); }
static int test_count();
static CcTest* last() { return last_; }
CcTest* prev() { return prev_; }
const char* file() { return file_; }
const char* name() { return name_; }
+ bool enabled() { return enabled_; }
private:
TestFunction* callback_;
const char* file_;
const char* name_;
+ bool enabled_;
static CcTest* last_;
CcTest* prev_;
};
MessageQueueDebuggerThread message_queue_debugger_thread;
// This thread runs the v8 engine.
-TEST(MessageQueues) {
+DISABLED_TEST(MessageQueues) {
// Create a V8 environment
v8::HandleScope scope;
DebugLocalContext env;
DebuggerThread debugger_thread;
V8Thread v8_thread;
-TEST(ThreadedDebugging) {
+DISABLED_TEST(ThreadedDebugging) {
// Create a V8 environment
threaded_debugging_barriers.Initialize();
BreakpointsDebuggerThread breakpoints_debugger_thread;
BreakpointsV8Thread breakpoints_v8_thread;
-TEST(RecursiveBreakpoints) {
+DISABLED_TEST(RecursiveBreakpoints) {
// Create a V8 environment
Barriers stack_allocated_breakpoints_barriers;
stack_allocated_breakpoints_barriers.Initialize();