Skip to content
Snippets Groups Projects
Commit 2aacfba8 authored by Florian Quèze's avatar Florian Quèze
Browse files

Bug 1828178 - Profiler tests should not fail when MOZ_PROFILER_STARTUP is set...

Bug 1828178 - Profiler tests should not fail when MOZ_PROFILER_STARTUP is set in the environment, r=canaltinova.

Differential Revision: https://phabricator.services.mozilla.com/D175512
parent a24990cd
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,7 @@ add_task(async () => {
const utilityPid = await startUtilityProcess();
info("Start the profiler");
startProfiler();
await startProfiler();
let profile;
await TestUtils.waitForCondition(async () => {
......
......@@ -24,11 +24,6 @@ async function waitForLoad() {
* Test the IPCMessages feature.
*/
add_task(async function test_profile_feature_ipcmessges() {
Assert.ok(
!Services.profiler.IsActive(),
"The profiler is not currently active"
);
const url = BASE_URL + "simple.html";
info("Open a tab while profiling IPC messages.");
......
......@@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* globals Assert */
/* globals info */
/**
* This file contains utilities that can be shared between xpcshell tests and mochitests.
......@@ -27,11 +28,28 @@ const defaultSettings = {
// Effectively `async`: Start the profiler and return the `startProfiler`
// promise that will get resolved when all child process have started their own
// profiler.
function startProfiler(callersSettings) {
async function startProfiler(callersSettings) {
if (Services.profiler.IsActive()) {
throw new Error(
"The profiler must not be active before starting it in a test."
Assert.ok(
Services.env.exists("MOZ_PROFILER_STARTUP"),
"The profiler is active at the begining of the test, " +
"the MOZ_PROFILER_STARTUP environment variable should be set."
);
if (Services.env.exists("MOZ_PROFILER_STARTUP")) {
// If the startup profiling environment variable exists, it is likely
// that tests are being profiled.
// Stop the profiler before starting profiler tests.
info(
"This test starts and stops the profiler and is not compatible " +
"with the use of MOZ_PROFILER_STARTUP. " +
"Stopping the profiler before starting the test."
);
await Services.profiler.StopProfiler();
} else {
throw new Error(
"The profiler must not be active before starting it in a test."
);
}
}
const settings = Object.assign({}, defaultSettings, callersSettings);
return Services.profiler.StartProfiler(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment