tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

metadata.ts (945B)


      1 import { assert } from '../util/util.js';
      2 
      3 /** Metadata about tests (that can't be derived at runtime). */
      4 export type TestMetadata = {
      5  /**
      6   * Estimated average time-per-subcase, in milliseconds.
      7   * This is used to determine chunking granularity when exporting to WPT with
      8   * chunking enabled (like out-wpt/cts-chunked2sec.https.html).
      9   */
     10  subcaseMS: number;
     11 };
     12 
     13 export type TestMetadataListing = {
     14  [testQuery: string]: TestMetadata;
     15 };
     16 
     17 export function loadMetadataForSuite(suiteDir: string): TestMetadataListing | null {
     18  assert(typeof require !== 'undefined', 'loadMetadataForSuite is only implemented on Node');
     19  /* eslint-disable-next-line n/no-restricted-require */
     20  const fs = require('fs');
     21 
     22  const metadataFile = `${suiteDir}/listing_meta.json`;
     23  if (!fs.existsSync(metadataFile)) {
     24    return null;
     25  }
     26 
     27  const metadata: TestMetadataListing = JSON.parse(fs.readFileSync(metadataFile, 'utf8'));
     28  return metadata;
     29 }