From da27189f09c185089cd77b8ea5199b66a6c031c0 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 15 Oct 2025 14:52:26 -0300 Subject: test, urls: get content-function unit test infra working, probably --- src/url-spec.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/url-spec.js') diff --git a/src/url-spec.js b/src/url-spec.js index 75cd8006..2e8b9fc1 100644 --- a/src/url-spec.js +++ b/src/url-spec.js @@ -1,6 +1,7 @@ // Exports defined here are re-exported through urls.js, // so they're generally imported from '#urls'. +import {readFileSync} from 'node:fs'; import {readFile} from 'node:fs/promises'; import * as path from 'node:path'; import {fileURLToPath} from 'node:url'; @@ -195,6 +196,24 @@ export async function processURLSpecFromFile(file) { error => annotateErrorWithFile(error, file)); } + return processURLSpecFromFileContents(file, contents); +} + +export function processURLSpecFromFileSync(file) { + let contents; + + try { + contents = readFileSync(file, 'utf-8'); + } catch (caughtError) { + throw annotateError( + new Error(`Failed to read URL spec file`, {cause: caughtError}), + error => annotateErrorWithFile(error, file)); + } + + return processURLSpecFromFileContents(file, contents); +} + +function processURLSpecFromFileContents(file, contents) { let sourceSpec; let parseLanguage; -- cgit 1.3.0-6-gf8a5