@@ -60,18 +60,26 @@ using ArrayBufferUniquePtr = std::unique_ptr<node::ArrayBufferAllocator,
60
60
using TracingAgentUniquePtr = std::unique_ptr<node::tracing::Agent>;
61
61
using NodePlatformUniquePtr = std::unique_ptr<node::NodePlatform>;
62
62
63
+ class NodeTestEnvironment final : public ::testing::Environment {
64
+ public:
65
+ NodeTestEnvironment () = default ;
66
+ void SetUp () override ;
67
+ void TearDown () override ;
68
+ };
69
+
70
+
63
71
class NodeZeroIsolateTestFixture : public ::testing::Test {
64
72
protected:
65
- static ArrayBufferUniquePtr allocator;
66
- static TracingAgentUniquePtr tracing_agent;
67
- static NodePlatformUniquePtr platform;
68
73
static uv_loop_t current_loop;
69
74
static bool node_initialized;
75
+ static ArrayBufferUniquePtr allocator;
76
+ static NodePlatformUniquePtr platform;
77
+ static TracingAgentUniquePtr tracing_agent;
70
78
71
79
static void SetUpTestCase () {
72
80
if (!node_initialized) {
73
- uv_os_unsetenv (" NODE_OPTIONS" );
74
81
node_initialized = true ;
82
+ uv_os_unsetenv (" NODE_OPTIONS" );
75
83
std::vector<std::string> argv { " cctest" };
76
84
std::vector<std::string> exec_argv;
77
85
std::vector<std::string> errors;
@@ -80,32 +88,22 @@ class NodeZeroIsolateTestFixture : public ::testing::Test {
80
88
CHECK_EQ (exitcode, 0 );
81
89
CHECK (errors.empty ());
82
90
}
83
-
84
- tracing_agent = std::make_unique<node::tracing::Agent>();
85
- node::tracing::TraceEventHelper::SetAgent (tracing_agent.get ());
86
- node::tracing::TracingController* tracing_controller =
87
- tracing_agent->GetTracingController ();
88
91
CHECK_EQ (0 , uv_loop_init (¤t_loop));
89
- static constexpr int kV8ThreadPoolSize = 4 ;
90
- platform.reset (
91
- new node::NodePlatform (kV8ThreadPoolSize , tracing_controller));
92
- v8::V8::InitializePlatform (platform.get ());
93
- v8::V8::Initialize ();
94
92
}
95
93
96
94
static void TearDownTestCase () {
97
- platform->Shutdown ();
98
95
while (uv_loop_alive (¤t_loop)) {
99
96
uv_run (¤t_loop, UV_RUN_ONCE);
100
97
}
101
- v8::V8::DisposePlatform ();
102
98
CHECK_EQ (0 , uv_loop_close (¤t_loop));
103
99
}
104
100
105
101
void SetUp () override {
106
102
allocator = ArrayBufferUniquePtr (node::CreateArrayBufferAllocator (),
107
103
&node::FreeArrayBufferAllocator);
108
104
}
105
+
106
+ friend NodeTestEnvironment;
109
107
};
110
108
111
109
0 commit comments