run-all-unittests.cc 1.53 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
// 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 {

12
class DefaultPlatformEnvironment final : public ::testing::Environment {
13
 public:
14
  DefaultPlatformEnvironment() = default;
15

16
  void SetUp() override {
17
    platform_ = v8::platform::NewDefaultPlatform(
18
        0, v8::platform::IdleTaskSupport::kEnabled);
19
    ASSERT_TRUE(platform_.get() != nullptr);
20
    v8::V8::InitializePlatform(platform_.get());
21 22 23
    ASSERT_TRUE(v8::V8::Initialize());
  }

24
  void TearDown() override {
25
    ASSERT_TRUE(platform_.get() != nullptr);
26 27 28 29 30
    v8::V8::Dispose();
    v8::V8::ShutdownPlatform();
  }

 private:
31
  std::unique_ptr<v8::Platform> platform_;
32 33 34 35 36 37
};

}  // namespace


int main(int argc, char** argv) {
38 39 40
  // Don't catch SEH exceptions and continue as the following tests might hang
  // in an broken environment on windows.
  testing::GTEST_FLAG(catch_exceptions) = false;
41 42 43 44

  // Most V8 unit-tests are multi-threaded, so enable thread-safe death-tests.
  testing::FLAGS_gtest_death_test_style = "threadsafe";

45 46 47
  testing::InitGoogleMock(&argc, argv);
  testing::AddGlobalTestEnvironment(new DefaultPlatformEnvironment);
  v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
vogelheim's avatar
vogelheim committed
48
  v8::V8::InitializeExternalStartupData(argv[0]);
49
  v8::V8::InitializeICUDefaultLocation(argv[0]);
50 51
  return RUN_ALL_TESTS();
}