test: rename spec files from -spec.ts to .spec.ts (#54258)

* test: rename spec files from -spec.ts to .spec.ts

Renames every spec/*-spec.ts file to spec/*.spec.ts and updates the
mocha file filter in spec/index.js, the glob in script/split-tests.js,
script/spec-weights.json, the macOS and Wayland spec allowlists, and
comments/docs that refer to spec files by name, so mocha and CI shard
splitting still pick up every spec file.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EoGAobkKTt7KNqEiajK2Gm

* test: fail spec runs on files still named -spec.ts

The spec runner only loads *.spec.ts, so a spec file still named
*-spec.ts (for example from a PR opened before the rename) would
silently never run. spec/index.js now throws before mocha starts if
one is present in spec/, so the test jobs go red instead. This is a
temporary guard for the transition.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EoGAobkKTt7KNqEiajK2Gm

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
claude[bot]andClaude Opus 5.5 authored and GitHub committed 2026-09-23 16:45:57 -07:00
1 parent 88833ddc7b
commit 1042d2998b
102 files changed
+907 -900

No files matched your search

@@ -268,7 +268,7 @@ For tests that can't be cleanly guarded inline, add the whole file to `script/no
**Behavioral differences (assertion updates, not skips)** — some errors just changed shape:
- Creating a private key from an unsupported OKP (Ed448) JWK now throws `Invalid JWK OKP key` (previously `Invalid JWK data`); see nodejs/node#62499. Electron's `spec/node-spec.ts` assertion was loosened to `/Invalid JWK/`.
- Creating a private key from an unsupported OKP (Ed448) JWK now throws `Invalid JWK OKP key` (previously `Invalid JWK data`); see nodejs/node#62499. Electron's `spec/node.spec.ts` assertion was loosened to `/Invalid JWK/`.
When you do need to guard a test, prefer a precise capability check (e.g. `ciphers.includes('aes-128-ccm')`) over a blanket `process.features.openssl_is_boringssl` check where the feature can be probed directly.
+1 -1
View File
@@ -81,7 +81,7 @@ When working on the `roller/chromium/main` branch for Chromium upgrades, use `e
- JS/TS files: kebab-case (`file-name.ts`)
- C++ files: snake_case with `electron_api_` prefix (`electron_api_safe_storage.cc`)
- Test files: `api-{module-name}-spec.ts` in `spec/`
- Test files: `api-{module-name}.spec.ts` in `spec/`
- Source file lists are maintained in `filenames.gni` (with platform-specific sections)
### JavaScript/TypeScript
+14 -14
View File
@@ -8,33 +8,33 @@
# Used by .github/workflows/pipeline-segment-electron-test.yml.
#
# private API symbol scan of every MAS binary (mas_avoid_private_macos_api_usage)
spec/mas-spec.ts
spec/mas.spec.ts
# app sandbox: getAppMetrics().sandboxed, startAccessingSecurityScopedResource,
# login items (electron_login_helper), process.mas gating
spec/api-app-spec.ts
spec/api-app.spec.ts
# security-scoped bookmarks returned by the open/save dialogs
spec/api-dialog-spec.ts
spec/api-dialog.spec.ts
# keychain account name differs in MAS builds (feat_ensure_mas_builds_..._safestorage)
spec/api-safe-storage-spec.ts
spec/api-safe-storage.spec.ts
# StoreKit, only meaningful for the App Store build
spec/api-in-app-purchase-spec.ts
spec/api-in-app-purchase.spec.ts
# frameless window mouseDown/swipe swizzling, no remote CoreAnimation,
# capturePage and hasCapturableScreen branches on process.mas
spec/api-browser-window-spec.ts
spec/api-browser-window.spec.ts
# screen capture without CGSSetWindowCaptureExcludeShape / remote CA
spec/api-desktop-capturer-spec.ts
spec/api-desktop-capturer.spec.ts
# ui/display/mac/screen_mac.mm is patched for MAS
spec/api-screen-spec.ts
spec/api-screen.spec.ts
# menu_controller_cocoa_delegate_impl.mm / NSToolbar private API removal
spec/api-menu-spec.ts
spec/api-menu.spec.ts
# forcefullyCrashRenderer without CrashDumpHungChildProcess, patched
# render_widget_host_view_mac paths
spec/api-web-contents-spec.ts
spec/api-web-contents.spec.ts
# sandboxMain branches on process.mas
spec/api-subframe-spec.ts
spec/api-subframe.spec.ts
# renderer/main crash paths without crashpad
spec/crash-spec.ts
spec/crash.spec.ts
# node_service.cc drops crash keys in MAS builds
spec/api-utility-process-spec.ts
spec/api-utility-process.spec.ts
# kill ring, font matching, remote cocoa and sandbox paths patched for MAS
spec/chromium-spec.ts
spec/chromium.spec.ts
+16 -16
View File
@@ -8,34 +8,34 @@
# label. Used by .github/workflows/pipeline-segment-electron-test.yml.
#
# Squirrel.Mac update lifecycle; unsigned-app cases only run on x64
spec/api-autoupdater-darwin-spec.ts
spec/api-autoupdater-darwin.spec.ts
# Squirrel.Mac update policy (version rules, tampered payloads, JSON mode)
spec/api-autoupdater-darwin-policy-spec.ts
spec/api-autoupdater-darwin-policy.spec.ts
# autoUpdater module API surface
spec/api-auto-updater-spec.ts
spec/api-auto-updater.spec.ts
# Node.js startup snapshot captures process.arch and friends; native addons
spec/node-spec.ts
spec/node.spec.ts
# electron_xcache: the Node startup snapshot / code cache blob for this arch
spec/xcache-spec.ts
spec/xcache.spec.ts
# js2c build-time V8 code cache and LoadBrowserProcessSpecificV8Snapshot
spec/api-js2c-code-cache-spec.ts
spec/api-js2c-code-cache.spec.ts
# sandboxed preload V8 code cache; the largest window-level surface
spec/api-browser-window-spec.ts
spec/api-browser-window.spec.ts
# codeCache for privileged custom protocols
spec/api-protocol-spec.ts
spec/api-protocol.spec.ts
# wasm-eval CSP, WebAssembly streaming compilation, workers, heap snapshots
spec/chromium-spec.ts
spec/chromium.spec.ts
# utility process Node isolate, ESM loading, heap snapshots near heap limit
spec/api-utility-process-spec.ts
spec/api-utility-process.spec.ts
# heap statistics, memory info and takeHeapSnapshot
spec/api-process-spec.ts
spec/api-process.spec.ts
# native module loading (compiled per arch) and uv_dlopen
spec/modules-spec.ts
spec/modules.spec.ts
# child_process.execFile out of asar has a darwin x64-only case
spec/asar-spec.ts
spec/asar.spec.ts
# runningUnderARM64Translation, x64-only recent-documents skip, sandbox options
spec/api-app-spec.ts
spec/api-app.spec.ts
# crashpad minidumps and stack walking are architecture specific
spec/api-crash-reporter-spec.ts
spec/api-crash-reporter.spec.ts
# renderer, main and node crash paths
spec/crash-spec.ts
spec/crash.spec.ts
+1 -1
View File
@@ -657,7 +657,7 @@ async function installSpecModules(dir) {
}
if (toolchainEnv === null) {
// Not silent: the specs covering these fixtures are gated on this
// variable and report as skipped, see spec/node-spec.ts.
// variable and report as skipped, see spec/node.spec.ts.
console.log(
`${warn} No compiler on this host can build Electron's headers, not rebuilding native addon '${addon}'; its specs will be skipped`
);
+844 -844
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -24,7 +24,7 @@ const path = require('node:path');
const currentShard = parseInt(process.argv[2], 10);
const shardCount = parseInt(process.argv[3], 10);
const specFiles = glob.sync('spec/*-spec.ts').map((f) => path.normalize(f));
const specFiles = glob.sync('spec/*.spec.ts').map((f) => path.normalize(f));
const BUILD_TYPES = { darwin: 'darwin', linux: 'linux', win32: 'win' };
+5 -5
View File
@@ -1,5 +1,5 @@
spec/parse-features-string-spec.ts
spec/types-spec.ts
spec/api-app-spec.ts
spec/api-browser-window-spec.ts
spec/api-clipboard-spec.ts
spec/parse-features-string.spec.ts
spec/types.spec.ts
spec/api-app.spec.ts
spec/api-browser-window.spec.ts
spec/api-clipboard.spec.ts
+1 -1
View File
@@ -2126,7 +2126,7 @@ void Initialize(v8::Local<v8::Object> exports,
}
dict.Set("app", app);
#if BUILDFLAG(IS_LINUX)
// For desktop-name-spec.
// For desktop-name.spec.
dict.SetMethod(
"defaultDesktopName",
base::BindRepeating([](std::optional<std::u16string> name) {
+1 -1
View File
@@ -44,4 +44,4 @@ However, I encountered multiple challenges during implementation. The current im
I use built-in OSR `offscreen: { useSharedTexture: true }` to obtain a exported shared texture, but you can use whatever you want with same requirements, you can even import at renderer process, in case you choose to load your native code in renderer process and correctly put the handle under that process. However, you need to make sure the shared handle is visible to that process.
To read the example, visit the test spec of this feature, start from [here](https://github.com/electron/electron/blob/main/spec/api-shared-texture-spec.ts). There's a detailed step by step comment in it, you'll also need to read [preload](https://github.com/electron/electron/blob/main/spec/fixtures/api/shared-texture/preload.js) and [renderer](https://github.com/electron/electron/blob/main/spec/fixtures/api/shared-texture/renderer.js) code to navigate throught all steps.
To read the example, visit the test spec of this feature, start from [here](https://github.com/electron/electron/blob/main/spec/api-shared-texture.spec.ts). There's a detailed step by step comment in it, you'll also need to read [preload](https://github.com/electron/electron/blob/main/spec/fixtures/api/shared-texture/preload.js) and [renderer](https://github.com/electron/electron/blob/main/spec/fixtures/api/shared-texture/renderer.js) code to navigate throught all steps.
+1 -1
View File
@@ -17,7 +17,7 @@
// code-cache key (source + params hash), so the build-time codecache generator
// (electron_natives_codecache_main.cc) must compile each bundle with the exact
// same params its runtime CompileAndCall site uses -- this header keeps both
// sides in sync. spec/api-js2c-code-cache-spec.ts also asserts every bundle's
// sides in sync. spec/api-js2c-code-cache.spec.ts also asserts every bundle's
// cache is consumed, catching any drift.
namespace electron::js2c {
+1 -1
View File
@@ -10,7 +10,7 @@
- Wait for the output you expect, not for `'exit'`. `utilityProcess` drops its
stdio listeners the moment the child exits, so a chunk still in the pipe when
`'exit'` fires is lost. Accumulate output until the expected pattern appears
(see `outputUntil` in `api-utility-process-spec.ts`), then assert on it.
(see `outputUntil` in `api-utility-process.spec.ts`), then assert on it.
- Don't assert on the first chunk from a pipe. stdout and stderr race, and a
stray warning on stderr (a `net/dns` config warning, a GPU message) can land
before the line you want. Match a pattern against the accumulated output.
File renamed without changes.
File renamed without changes.
@@ -13,7 +13,7 @@ import { ifdescribe } from './lib/spec-helpers.ts';
// When Squirrel.Mac refuses or alters an update: version rules, a running
// app, tampered payloads, JSON update mode and direct contents writes. The
// update lifecycle itself is in api-autoupdater-darwin-spec.ts; the two files
// update lifecycle itself is in api-autoupdater-darwin.spec.ts; the two files
// share a harness and are split so that they can land on different CI shards.
ifdescribe(shouldRunUpdaterSpecs)('autoUpdater behavior', function () {
this.timeout(120000);
@@ -9,7 +9,7 @@ import type { RoutedResponse } from './lib/http-server-helpers.ts';
// The update lifecycle: checking, downloading, staging, installing and
// relaunching. The rules for refusing or altering an update are in
// api-autoupdater-darwin-policy-spec.ts; the two files share a harness and
// api-autoupdater-darwin-policy.spec.ts; the two files share a harness and
// are split so that they can land on different CI shards.
ifdescribe(shouldRunUpdaterSpecs)('autoUpdater behavior', function () {
this.timeout(120000);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1526,7 +1526,7 @@ describe('protocol module', () => {
});
});
// protocol.registerSchemesAsPrivileged allowExtensions tests are in extensions-spec.ts.
// protocol.registerSchemesAsPrivileged allowExtensions tests are in extensions.spec.ts.
describe('handle', () => {
afterEach(closeAllWindows);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+4 -4
View File
@@ -1,5 +1,5 @@
// Runs test bodies from spec/api-net-spec.ts (and one from
// spec/api-app-spec.ts) inside a utility process. Each body arrives as source
// Runs test bodies from spec/api-net.spec.ts (and one from
// spec/api-app.spec.ts) inside a utility process. Each body arrives as source
// text, so everything it refers to from those spec files' imports has to be in
// scope here under the same name.
/* oxlint-disable @typescript-eslint/no-unused-vars */
@@ -41,7 +41,7 @@ function fail(message) {
}
process.parentPort.on('message', async (e) => {
// Equivalent of beforeEach in spec/api-net-spec.ts
// Equivalent of beforeEach in spec/api-net.spec.ts
respondNTimes.routeFailure = false;
try {
@@ -58,7 +58,7 @@ process.parentPort.on('message', async (e) => {
process.exit(1);
}
// Equivalent of afterEach in spec/api-net-spec.ts
// Equivalent of afterEach in spec/api-net.spec.ts
if (respondNTimes.routeFailure) {
fail(
'Failing this test due an unhandled error in the respondOnce route handler, check the logs above for the actual error'
+1 -1
View File
@@ -21,7 +21,7 @@ const exact = path.join(archive, 'exact.bin');
const small = path.join(archive, 'small.bin');
const BLOCK = 4 * 1024 * 1024;
// Must match the generator in asar-integrity-spec.ts.
// Must match the generator in asar-integrity.spec.ts.
const MULTI_SIZE = 2 * BLOCK + 1024 * 1024 + 5;
const EXACT_SIZE = BLOCK;
const SMALL_SIZE = 1000;
+1 -1
View File
@@ -2,7 +2,7 @@
//
// IMPORTANT: the line number of the `throw` below is asserted by the spec.
// If you edit this file, update the expected line number in
// api-browser-window-spec.ts ("preload script stack traces").
// api-browser-window.spec.ts ("preload script stack traces").
const { ipcRenderer } = require('electron');
try {
throw new Error('preload-stack-trace-marker'); // <-- line 8
File renamed without changes.
File renamed without changes.
+10 -3
View File
@@ -51,9 +51,9 @@ app.commandLine.appendSwitch(
app.commandLine.appendSwitch(
'enable-features',
[
// spec/api-web-frame-main-spec.ts
// spec/api-web-frame-main.spec.ts
'DocumentPolicyIncludeJSCallStacksInCrashReports',
// spec/spellchecker-spec.ts - allows spellcheck without user gesture
// spec/spellchecker.spec.ts - allows spellcheck without user gesture
// https://chromium-review.googlesource.com/c/chromium/src/+/7452579
'UnrestrictSpellingAndGrammarForTesting'
].join(',')
@@ -296,7 +296,7 @@ app
argv.files &&
argv.files.map((file) => (path.isAbsolute(file) ? path.relative(baseElectronDir, file) : path.normalize(file)));
const filter = (file) => {
if (!/-spec\.[tj]s$/.test(file)) {
if (!/\.spec\.[tj]s$/.test(file)) {
return false;
}
@@ -315,6 +315,13 @@ app
};
const { getFiles } = await import('./get-files.ts');
// The filter above only loads *.spec.ts, so a file still named *-spec.ts
// (e.g. from a PR opened before the rename) would silently never run.
const misnamed = await getFiles(import.meta.dirname, (file) => /-spec\.[cm]?[jt]sx?$/.test(file));
if (misnamed.length > 0) {
const names = misnamed.map((file) => path.relative(baseElectronDir, file)).join(', ');
throw new Error(`Spec files must be named *.spec.ts, rename: ${names}`);
}
const testFiles = await getFiles(import.meta.dirname, filter);
for (const file of testFiles.sort()) {
mocha.addFile(file);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -2,7 +2,7 @@ import { expect } from 'chai';
import { createRequire } from 'node:module';
// See deprecate-spec.ts for why this is require()d rather than imported.
// See deprecate.spec.ts for why this is require()d rather than imported.
const { parseCommaSeparatedKeyValue, parseFeatures }: typeof import('../lib/browser/parse-features-string.ts') =
createRequire(import.meta.url)('../lib/browser/parse-features-string.ts');
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 102 files, more files were not shown because too many files have changed in this diff. Show more