Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/glean-core/src/   (Firefox Browser Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 1 kB image not shown  

Quelle  coverage.rs

  Sprache: Rust
 

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

//! Utilities for recording when testing APIs have been called on specific
//! metrics.
//!
//! Testing coverage is enabled by setting the GLEAN_TEST_COVERAGE environment
//! variable to the name of an output file. This output file must run through a
//! post-processor (in glean_parser's `coverage` command) to convert to a format
//! understood by third-party coverage reporting tools.
//!
//! While running a unit test suite, Glean records which database keys were
//! accessed by the testing APIs, with one entry per line. Database keys are
//! usually, but not always, the same as metric identifiers, but it is the
//! responsibility of the post-processor to resolve that difference.
//!
//! This functionality has no runtime overhead unless the testing API is used.

use std::env;
use std::fs::{File, OpenOptions};
use std::io::Write;
use std::sync::Mutex;

use once_cell::sync::Lazy;

static COVERAGE_FILE: Lazy<Option<Mutex<File>>> = Lazy::new(|| {
    if let Some(filename) = env::var_os("GLEAN_TEST_COVERAGE") {
        match OpenOptions::new().append(true).create(true).open(filename) {
            Ok(file) => {
                return Some(Mutex::new(file));
            }
            Err(err) => {
                log::error!("Couldn't open file for coverage results: {:?}", err);
            }
        }
    }
    None
});

pub(cratefn record_coverage(metric_id: &str) {
    if let Some(file_mutex) = &*COVERAGE_FILE {
        let mut file = file_mutex.lock().unwrap();
        writeln!(&mut file, "{}", metric_id).ok();
        file.flush().ok();
    }
}

Messung V0.5 in Prozent
C=88 H=99 G=93

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet am  2026-06-18) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.