Open Bug 1756055 Opened 3 years ago Updated 5 months ago

Can we do away with do_get_profile and Services.fog.initializeFOG in xpcshell?

Categories

(Toolkit :: Telemetry, task, P4)

task

Tracking

()

People

(Reporter: chutten, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [telemetry:fog:m?])

It sucks that FOG instrumentation tests all need the same front matter:

// FOG needs a profile directory to store its info.
do_get_profile();
// FOG needs to be initialized exactly once.
Services.fog.initializeFOG();

Is there anything we can do about this?

An idea: the only part of do_get_profile() that FOG needs is ProfD. Maybe we can do that part cheaply before every test file in head.js? Like maybe here? And then, thereafter, is initializeFOG cheap enough for us to run unconditionally? Is there a mode of initialization we could run unconditionally?

If not, is there a clever JS thing we could do to intercept test methods and ensure FOG is init the first time they're called?

Maybe we can make this nice.

Priority: -- → P4
See Also: → 1980131

Can we make testGetValue (and/or other similar methods) throw if initializeFOG was never called and/or there's no ProfD?

Flags: needinfo?(chutten)

(In reply to :Gijs (he/him) from comment #1)

Can we make testGetValue (and/or other similar methods) throw if initializeFOG was never called and/or there's no ProfD?

Yes, but we'd have to write a lot of copy-pasta to make it happen and it's very possible that new metric types would forget to check. I'd prefer to have do_get_profile(); Services.fog.initializeFOG(); unconditionally run on xpcshell tests if possible, because that would be the easier-to-maintain and more ergonomic result.

Flags: needinfo?(chutten)
You need to log in before you can comment on or make changes to this bug.