+++ /dev/null
-# TODO(bmeurer): Temporary work-around, will be fixed soonish.
-include_rules = [
- "+include/libplatform/libplatform.h"
-]
// found in the LICENSE file.
#include "src/compiler/change-lowering.h"
+#include "src/compiler/compiler-test-utils.h"
#include "src/compiler/graph-unittest.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/node-properties-inl.h"
// found in the LICENSE file.
#include "src/compiler/common-operator.h"
-#include "src/compiler/compiler-unittests.h"
#include "src/compiler/operator-properties-inl.h"
+#include "src/test/test-utils.h"
namespace v8 {
namespace internal {
namespace {
-class CommonOperatorTest : public CompilerTest {
+class CommonOperatorTest : public TestWithZone {
public:
CommonOperatorTest() : common_(zone()) {}
virtual ~CommonOperatorTest() {}
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef V8_COMPILER_UNITTESTS_COMPILER_UNITTESTS_H_
-#define V8_COMPILER_UNITTESTS_COMPILER_UNITTESTS_H_
+#ifndef V8_COMPILER_COMPILER_TEST_UTILS_H_
+#define V8_COMPILER_COMPILER_TEST_UTILS_H_
-#include "include/v8.h"
-#include "src/zone.h"
-#include "testing/gtest-support.h"
+#include "testing/gtest/include/gtest/gtest.h"
namespace v8 {
namespace internal {
-
-// Forward declarations.
-class Factory;
-
-
namespace compiler {
// The TARGET_TEST(Case, Name) macro works just like
#define TARGET_TYPED_TEST(Case, Name) TYPED_TEST(Case, DISABLED_##Name)
#endif
-
-class CompilerTest : public ::testing::Test {
- public:
- CompilerTest();
- virtual ~CompilerTest();
-
- Factory* factory() const;
- Isolate* isolate() const { return reinterpret_cast<Isolate*>(isolate_); }
- Zone* zone() { return &zone_; }
-
- static void SetUpTestCase();
- static void TearDownTestCase();
-
- private:
- static v8::Isolate* isolate_;
- v8::Isolate::Scope isolate_scope_;
- v8::HandleScope handle_scope_;
- v8::Context::Scope context_scope_;
- Zone zone_;
-};
-
-
-template <typename T>
-class CompilerTestWithParam : public CompilerTest,
- public ::testing::WithParamInterface<T> {};
-
} // namespace compiler
} // namespace internal
} // namespace v8
-#endif // V8_COMPILER_UNITTESTS_COMPILER_UNITTESTS_H_
+#endif // V8_COMPILER_COMPILER_TEST_UTILS_H_
+++ /dev/null
-// Copyright 2014 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "include/libplatform/libplatform.h"
-#include "src/compiler/compiler-unittests.h"
-#include "src/isolate-inl.h"
-#include "testing/gmock/include/gmock/gmock.h"
-
-using testing::IsNull;
-using testing::NotNull;
-
-namespace v8 {
-namespace internal {
-namespace compiler {
-
-// static
-v8::Isolate* CompilerTest::isolate_ = NULL;
-
-
-CompilerTest::CompilerTest()
- : isolate_scope_(isolate_),
- handle_scope_(isolate_),
- context_scope_(v8::Context::New(isolate_)),
- zone_(isolate()) {}
-
-
-CompilerTest::~CompilerTest() {}
-
-
-Factory* CompilerTest::factory() const { return isolate()->factory(); }
-
-
-// static
-void CompilerTest::SetUpTestCase() {
- Test::SetUpTestCase();
- EXPECT_THAT(isolate_, IsNull());
- isolate_ = v8::Isolate::New();
- ASSERT_THAT(isolate_, NotNull());
-}
-
-
-// static
-void CompilerTest::TearDownTestCase() {
- ASSERT_THAT(isolate_, NotNull());
- isolate_->Dispose();
- isolate_ = NULL;
- Test::TearDownTestCase();
-}
-
-} // namespace compiler
-} // namespace internal
-} // namespace v8
-
-
-namespace {
-
-class CompilerTestEnvironment FINAL : public ::testing::Environment {
- public:
- CompilerTestEnvironment() : platform_(NULL) {}
- ~CompilerTestEnvironment() {}
-
- virtual void SetUp() OVERRIDE {
- EXPECT_THAT(platform_, IsNull());
- platform_ = v8::platform::CreateDefaultPlatform();
- v8::V8::InitializePlatform(platform_);
- ASSERT_TRUE(v8::V8::Initialize());
- }
-
- virtual void TearDown() OVERRIDE {
- ASSERT_THAT(platform_, NotNull());
- v8::V8::Dispose();
- v8::V8::ShutdownPlatform();
- delete platform_;
- platform_ = NULL;
- }
-
- private:
- v8::Platform* platform_;
-};
-
-} // namespace
-
-
-int main(int argc, char** argv) {
- testing::InitGoogleMock(&argc, argv);
- testing::AddGlobalTestEnvironment(new CompilerTestEnvironment);
- v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
- return RUN_ALL_TESTS();
-}
'target_name': 'compiler-unittests',
'type': 'executable',
'dependencies': [
- '../../testing/gmock.gyp:gmock',
- '../../testing/gtest.gyp:gtest',
- '../../tools/gyp/v8.gyp:v8_libplatform',
+ '../test/test.gyp:run-all-unittests',
],
'include_dirs': [
'../..',
'sources': [ ### gcmole(all) ###
'change-lowering-unittest.cc',
'common-operator-unittest.cc',
- 'compiler-unittests.cc',
- 'compiler-unittests.h',
+ 'compiler-test-utils.h',
'graph-unittest.cc',
'graph-unittest.h',
'instruction-selector-unittest.cc',
'x64/instruction-selector-x64-unittest.cc',
],
}],
- ['component=="shared_library"', {
- # compiler-unittests can't be built against a shared library, so we
- # need to depend on the underlying static target in that case.
- 'conditions': [
- ['v8_use_snapshot=="true"', {
- 'dependencies': ['../../tools/gyp/v8.gyp:v8_snapshot'],
- },
- {
- 'dependencies': [
- '../../tools/gyp/v8.gyp:v8_nosnapshot',
- ],
- }],
- ],
- }, {
- 'dependencies': ['../../tools/gyp/v8.gyp:v8'],
- }],
- ['os_posix == 1', {
- # TODO(svenpanne): This is a temporary work-around to fix the warnings
- # that show up because we use -std=gnu++0x instead of -std=c++11.
- 'cflags!': [
- '-pedantic',
- ],
- }],
],
},
],
#define V8_COMPILER_GRAPH_UNITTEST_H_
#include "src/compiler/common-operator.h"
-#include "src/compiler/compiler-unittests.h"
#include "src/compiler/graph.h"
#include "src/compiler/machine-operator.h"
+#include "src/test/test-utils.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace v8 {
using ::testing::Matcher;
-class GraphTest : public CompilerTest {
+class GraphTest : public TestWithContext, public TestWithZone {
public:
explicit GraphTest(int parameters = 1);
virtual ~GraphTest();
#include "src/compiler/instruction-selector-unittest.h"
+#include "src/compiler/compiler-test-utils.h"
#include "src/flags.h"
namespace v8 {
InstructionSelectorTest::InstructionSelectorTest() : rng_(FLAG_random_seed) {}
+InstructionSelectorTest::~InstructionSelectorTest() {}
+
+
InstructionSelectorTest::Stream InstructionSelectorTest::StreamBuilder::Build(
InstructionSelector::Features features,
InstructionSelectorTest::StreamBuilderMode mode) {
#include <set>
#include "src/base/utils/random-number-generator.h"
-#include "src/compiler/compiler-unittests.h"
#include "src/compiler/instruction-selector.h"
#include "src/compiler/raw-machine-assembler.h"
+#include "src/test/test-utils.h"
namespace v8 {
namespace internal {
namespace compiler {
-class InstructionSelectorTest : public CompilerTest {
+class InstructionSelectorTest : public TestWithContext, public TestWithZone {
public:
InstructionSelectorTest();
- virtual ~InstructionSelectorTest() {}
+ virtual ~InstructionSelectorTest();
base::RandomNumberGenerator* rng() { return &rng_; }
public:
explicit MachineOperatorReducerTest(int num_parameters = 2)
: GraphTest(num_parameters), machine_(zone()) {}
- virtual ~MachineOperatorReducerTest() {}
protected:
Reduction Reduce(Node* node) {
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "src/compiler/compiler-unittests.h"
#include "src/compiler/machine-operator.h"
#include "src/compiler/operator-properties-inl.h"
-#include "testing/gmock/include/gmock/gmock.h"
-
-using testing::IsNull;
+#include "src/test/test-utils.h"
namespace v8 {
namespace internal {
namespace compiler {
-class MachineOperatorCommonTest : public CompilerTestWithParam<MachineType> {
+class MachineOperatorCommonTest
+ : public TestWithZone,
+ public ::testing::WithParamInterface<MachineType> {
public:
MachineOperatorCommonTest() : machine_(NULL) {}
- virtual ~MachineOperatorCommonTest() { EXPECT_THAT(machine_, IsNull()); }
+ virtual ~MachineOperatorCommonTest() { EXPECT_EQ(NULL, machine_); }
virtual void SetUp() OVERRIDE {
- CompilerTestWithParam<MachineType>::SetUp();
+ TestWithZone::SetUp();
+ EXPECT_EQ(NULL, machine_);
machine_ = new MachineOperatorBuilder(zone(), GetParam());
}
virtual void TearDown() OVERRIDE {
+ ASSERT_TRUE(machine_ != NULL);
delete machine_;
machine_ = NULL;
- CompilerTestWithParam<MachineType>::TearDown();
+ TestWithZone::TearDown();
}
protected:
--- /dev/null
+include_rules = [
+ "+include/libplatform/libplatform.h"
+]
--- /dev/null
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "include/libplatform/libplatform.h"
+#include "include/v8.h"
+#include "src/base/compiler-specific.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+namespace {
+
+class DefaultPlatformEnvironment FINAL : public ::testing::Environment {
+ public:
+ DefaultPlatformEnvironment() : platform_(NULL) {}
+ ~DefaultPlatformEnvironment() {}
+
+ virtual void SetUp() OVERRIDE {
+ EXPECT_EQ(NULL, platform_);
+ platform_ = v8::platform::CreateDefaultPlatform();
+ ASSERT_TRUE(platform_ != NULL);
+ v8::V8::InitializePlatform(platform_);
+ ASSERT_TRUE(v8::V8::Initialize());
+ }
+
+ virtual void TearDown() OVERRIDE {
+ ASSERT_TRUE(platform_ != NULL);
+ v8::V8::Dispose();
+ v8::V8::ShutdownPlatform();
+ delete platform_;
+ platform_ = NULL;
+ }
+
+ private:
+ v8::Platform* platform_;
+};
+
+} // namespace
+
+
+int main(int argc, char** argv) {
+ testing::InitGoogleMock(&argc, argv);
+ testing::AddGlobalTestEnvironment(new DefaultPlatformEnvironment);
+ v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
+ return RUN_ALL_TESTS();
+}
--- /dev/null
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/test/test-utils.h"
+
+#include "src/isolate-inl.h"
+
+namespace v8 {
+
+// static
+Isolate* TestWithIsolate::isolate_ = NULL;
+
+
+TestWithIsolate::TestWithIsolate()
+ : isolate_scope_(isolate()), handle_scope_(isolate()) {}
+
+
+TestWithIsolate::~TestWithIsolate() {}
+
+
+// static
+void TestWithIsolate::SetUpTestCase() {
+ Test::SetUpTestCase();
+ EXPECT_EQ(NULL, isolate_);
+ isolate_ = v8::Isolate::New();
+ EXPECT_TRUE(isolate_ != NULL);
+}
+
+
+// static
+void TestWithIsolate::TearDownTestCase() {
+ ASSERT_TRUE(isolate_ != NULL);
+ isolate_->Dispose();
+ isolate_ = NULL;
+ Test::TearDownTestCase();
+}
+
+
+TestWithContext::TestWithContext()
+ : context_(Context::New(isolate())), context_scope_(context_) {}
+
+
+TestWithContext::~TestWithContext() {}
+
+
+namespace internal {
+
+TestWithIsolate::~TestWithIsolate() {}
+
+
+Factory* TestWithIsolate::factory() const { return isolate()->factory(); }
+
+
+TestWithZone::~TestWithZone() {}
+
+} // namespace internal
+} // namespace v8
--- /dev/null
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_TEST_TEST_UTILS_H_
+#define V8_TEST_TEST_UTILS_H_
+
+#include "include/v8.h"
+#include "src/base/macros.h"
+#include "src/zone.h"
+#include "testing/gtest-support.h"
+
+namespace v8 {
+
+class TestWithIsolate : public ::testing::Test {
+ public:
+ TestWithIsolate();
+ virtual ~TestWithIsolate();
+
+ Isolate* isolate() const { return isolate_; }
+
+ static void SetUpTestCase();
+ static void TearDownTestCase();
+
+ private:
+ static Isolate* isolate_;
+ Isolate::Scope isolate_scope_;
+ HandleScope handle_scope_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestWithIsolate);
+};
+
+
+class TestWithContext : public virtual TestWithIsolate {
+ public:
+ TestWithContext();
+ virtual ~TestWithContext();
+
+ const Local<Context>& context() const { return context_; }
+
+ private:
+ Local<Context> context_;
+ Context::Scope context_scope_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestWithContext);
+};
+
+
+namespace internal {
+
+// Forward declarations.
+class Factory;
+
+
+class TestWithIsolate : public virtual ::v8::TestWithIsolate {
+ public:
+ TestWithIsolate() {}
+ virtual ~TestWithIsolate();
+
+ Factory* factory() const;
+ Isolate* isolate() const {
+ return reinterpret_cast<Isolate*>(::v8::TestWithIsolate::isolate());
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TestWithIsolate);
+};
+
+
+class TestWithZone : public TestWithIsolate {
+ public:
+ TestWithZone() : zone_(isolate()) {}
+ virtual ~TestWithZone();
+
+ Zone* zone() { return &zone_; }
+
+ private:
+ Zone zone_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestWithZone);
+};
+
+} // namespace internal
+} // namespace v8
+
+#endif // V8_TEST_TEST_UTILS_H_
--- /dev/null
+# Copyright 2014 the V8 project authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+ 'variables': {
+ 'v8_code': 1,
+ },
+ 'includes': ['../../build/toolchain.gypi', '../../build/features.gypi'],
+ 'targets': [
+ {
+ 'target_name': 'run-all-unittests',
+ 'type': 'static_library',
+ 'variables': {
+ 'optimize': 'max',
+ },
+ 'dependencies': [
+ '../../testing/gmock.gyp:gmock',
+ '../../testing/gtest.gyp:gtest',
+ '../../tools/gyp/v8.gyp:v8_libplatform',
+ ],
+ 'include_dirs': [
+ '../..',
+ ],
+ 'sources': [ ### gcmole(all) ###
+ 'run-all-unittests.cc',
+ 'test-utils.h',
+ 'test-utils.cc',
+ ],
+ 'export_dependent_settings': [
+ '../../testing/gmock.gyp:gmock',
+ '../../testing/gtest.gyp:gtest',
+ ],
+ 'conditions': [
+ ['component=="shared_library"', {
+ # compiler-unittests can't be built against a shared library, so we
+ # need to depend on the underlying static target in that case.
+ 'conditions': [
+ ['v8_use_snapshot=="true"', {
+ 'dependencies': ['../../tools/gyp/v8.gyp:v8_snapshot'],
+ },
+ {
+ 'dependencies': [
+ '../../tools/gyp/v8.gyp:v8_nosnapshot',
+ ],
+ }],
+ ],
+ }, {
+ 'dependencies': ['../../tools/gyp/v8.gyp:v8'],
+ }],
+ ['os_posix == 1', {
+ # TODO(svenpanne): This is a temporary work-around to fix the warnings
+ # that show up because we use -std=gnu++0x instead of -std=c++11.
+ 'cflags!': [
+ '-pedantic',
+ ],
+ 'direct_dependent_settings': {
+ 'cflags!': [
+ '-pedantic',
+ ],
+ },
+ }],
+ ['want_separate_host_toolset==1', {
+ 'toolsets': ['host', 'target'],
+ }, {
+ 'toolsets': ['target'],
+ }],
+ ],
+ },
+ ],
+}
'export_dependent_settings': [
'gtest.gyp:gtest',
],
+ 'conditions': [
+ ['want_separate_host_toolset==1', {
+ 'toolsets': ['host', 'target'],
+ }, {
+ 'toolsets': ['target'],
+ }],
+ ],
},
{
'target_name': 'gmock_main',