From cc4d60e0c6b91b3465e8b66676cabc3bbeb8be68 Mon Sep 17 00:00:00 2001 From: zorkow Date: Wed, 22 Oct 2025 12:54:28 +0200 Subject: [PATCH 1/3] generalise report tmp file --- testsuite/src/constants.js | 6 +++++- testsuite/src/texReporter.js | 4 +--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/testsuite/src/constants.js b/testsuite/src/constants.js index ed7778d84..0623df1bd 100644 --- a/testsuite/src/constants.js +++ b/testsuite/src/constants.js @@ -1 +1,5 @@ -export const tmpJsonFile = '/tmp/test.json'; +import * as os from 'os'; + +export const tmpJsonFile = os.tmpdir() + '/test.json'; +export const ESC = '\u001B'; + diff --git a/testsuite/src/texReporter.js b/testsuite/src/texReporter.js index 1f037fb44..1fb0c0c83 100644 --- a/testsuite/src/texReporter.js +++ b/testsuite/src/texReporter.js @@ -2,11 +2,9 @@ * Custom reporter for tex macro coverage. */ -import {tmpJsonFile} from './constants.js'; +import { tmpJsonFile, ESC } from './constants.js'; import * as fs from 'fs'; -const ESC = '\u001B'; - export default class TexReporter { constructor(globalConfig, reporterOptions, reporterContext) { From 8963392cb38b7cbd4a1537c7a0671554c1f34932 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 30 Dec 2025 11:35:42 -0500 Subject: [PATCH 2/3] Update windows paths to include file:// and fix tests. (mathjax/MathJax#3481). --- testsuite/tests/util/Context-windows.test.ts | 7 ++++--- ts/util/asyncLoad/system.ts | 7 ++++++- ts/util/context.ts | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/testsuite/tests/util/Context-windows.test.ts b/testsuite/tests/util/Context-windows.test.ts index 8b8550e40..68a6bbee8 100644 --- a/testsuite/tests/util/Context-windows.test.ts +++ b/testsuite/tests/util/Context-windows.test.ts @@ -7,9 +7,10 @@ describe('context object', () => { test('context', async () => { let {context, hasWindow} = await import("#js/util/context.js"); - expect(context.path('C:\\test.js')).toBe('C:/test.js'); - expect(context.path('/C:/test.js')).toBe('C:/test.js'); - expect(context.path('/test.js')).toBe('/test.js'); + expect(context.path('C:\\test.js')).toBe('file://C:/test.js'); + expect(context.path('/C:/test.js')).toBe('file://C:/test.js'); + expect(context.path('/test.js')).toBe('file:///test.js'); + expect(context.path('./test.js')).toBe('./test.js'); delete context.path; expect(context).toEqual({window: window, document: window.document, os: 'Windows'}); expect(hasWindow).toBe(true); diff --git a/ts/util/asyncLoad/system.ts b/ts/util/asyncLoad/system.ts index 42b227b9a..c950babe9 100644 --- a/ts/util/asyncLoad/system.ts +++ b/ts/util/asyncLoad/system.ts @@ -27,7 +27,12 @@ import { context } from '../context.js'; declare const System: { import: (name: string, url?: string) => any }; declare const __dirname: string; -let root = 'file://' + context.path(__dirname).replace(/\/[^/]*\/[^/]*$/, '/'); +let root = + 'file://' + + context + .path(__dirname) + .replace(/\/[^/]*\/[^/]*$/, '/') + .replace(/^file:\/\//, ''); if (!mathjax.asyncLoad && typeof System !== 'undefined' && System.import) { mathjax.asyncLoad = (name: string) => { diff --git a/ts/util/context.ts b/ts/util/context.ts index 4f5b216b3..284785aaa 100644 --- a/ts/util/context.ts +++ b/ts/util/context.ts @@ -75,6 +75,6 @@ export const context = { if (context.os === 'Windows') { context.path = (file: string) => file.match(/^[/\\]?[a-zA-Z]:[/\\]/) - ? file.replace(/\\/g, '/').replace(/^\//, '') - : file; + ? 'file://' + file.replace(/\\/g, '/').replace(/^\//, '') + : file.replace(/^\//, 'file:///'); } From 4c230625c4d1eb426b696f16d8fe2d8d113e5b4b Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Thu, 8 Jan 2026 06:45:21 -0500 Subject: [PATCH 3/3] Fix test broken by context.path change. --- testsuite/tests/util/Context-node.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/tests/util/Context-node.test.ts b/testsuite/tests/util/Context-node.test.ts index 4c5fc15fe..c0d281dd8 100644 --- a/testsuite/tests/util/Context-node.test.ts +++ b/testsuite/tests/util/Context-node.test.ts @@ -19,7 +19,7 @@ describe('context object', () => { test('context', () => { if (OS === 'Windows') { - expect(context.path('C:\\test.js')).toBe('C:/test.js'); + expect(context.path('C:\\test.js')).toBe('file:///C:/test.js'); } else { expect(context.path('C:\\test.js')).toBe('C:\\test.js'); }