* gjs_coverage_write_statistics: * @self: A #GjsCoverage * @output_directory: A directory to write coverage information to. * * Scripts which were provided as part of the #GjsCoverage:prefixes construction * property will be written out to @output_directory, in the same directory * structure relative to the source dir where the tests were run. * * This function takes all available statisti
| 283 | * ending with ".js" in the coverage directories. |
| 284 | */ |
| 285 | void gjs_coverage_write_statistics(GjsCoverage* self) { |
| 286 | auto* priv = static_cast<GjsCoveragePrivate*>( |
| 287 | gjs_coverage_get_instance_private(self)); |
| 288 | auto* cx = static_cast<JSContext*>( |
| 289 | gjs_context_get_native_context(priv->coverage_context)); |
| 290 | Gjs::AutoMainRealm ar{cx}; |
| 291 | |
| 292 | GErrorResult<Gjs::AutoUnref<GFile>> result{ |
| 293 | write_statistics_internal(self, cx)}; |
| 294 | if (result.isErr()) { |
| 295 | g_critical("Error writing coverage data: %s", |
| 296 | result.inspectErr()->message); |
| 297 | return; |
| 298 | } |
| 299 | |
| 300 | Gjs::AutoChar output_file_path{g_file_get_path(result.unwrap())}; |
| 301 | g_message("Wrote coverage statistics to %s", output_file_path.get()); |
| 302 | } |
| 303 | |
| 304 | static void gjs_coverage_init(GjsCoverage*) { |
| 305 | if (!s_coverage_enabled) |