Skip to content

Commit f1e00cb

Browse files
committed
test: skip linux-only qa suites on non-linux
1 parent 728b292 commit f1e00cb

4 files changed

Lines changed: 55 additions & 0 deletions

File tree

scripts/qa-platform.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* 判断某个 QA 分支是否只应在 Linux 上执行。
3+
*
4+
* `fnos` 这类依赖 Bash / Linux 文件系统语义的测试在非 Linux 平台上
5+
* 没有稳定意义,因此这里统一提供平台判定 helper,避免在多个 QA 入口里散落条件。
6+
*
7+
* @param {string} [platform=process.platform] Node 运行时平台标识。
8+
* @returns {boolean} 仅当平台为 `linux` 时返回 `true`。
9+
*/
10+
export function shouldRunLinuxOnlyQa(platform = process.platform) {
11+
return platform === 'linux'
12+
}

scripts/qa-platform.test.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import test from 'node:test'
2+
import assert from 'node:assert/strict'
3+
4+
import { shouldRunLinuxOnlyQa } from './qa-platform.mjs'
5+
6+
test('shouldRunLinuxOnlyQa returns true on linux', () => {
7+
assert.equal(shouldRunLinuxOnlyQa('linux'), true)
8+
})
9+
10+
test('shouldRunLinuxOnlyQa returns false on non-linux platforms', () => {
11+
assert.equal(shouldRunLinuxOnlyQa('win32'), false)
12+
assert.equal(shouldRunLinuxOnlyQa('darwin'), false)
13+
})

scripts/qa-turbo.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { spawnSync } from 'node:child_process'
44
import { buildPnpmCommand } from './pnpm-command.mjs'
5+
import { shouldRunLinuxOnlyQa } from './qa-platform.mjs'
56

67
// Turbo 版 QA 编排器。
78
// 这个入口把 workspace QA 拆成可缓存、可并行的任务链,优先服务速度和 affected 场景;
@@ -332,6 +333,13 @@ function runRootPwshQa(modeValue, sinceRef) {
332333
}
333334

334335
function runRootFnosQa(modeValue, sinceRef) {
336+
if (!shouldRunLinuxOnlyQa()) {
337+
console.log(
338+
`[turbo:qa] skip root qa:fnos (linux only, current platform: ${process.platform})`,
339+
)
340+
return
341+
}
342+
335343
if (modeValue === 'all') {
336344
console.log('[turbo:qa] run root qa:fnos (all)')
337345
const pnpmCommand = buildPnpmCommand(['run', 'qa:fnos'])
@@ -352,6 +360,13 @@ function runRootFnosQa(modeValue, sinceRef) {
352360
}
353361

354362
function runRootSystemdServiceManagerQa(modeValue, sinceRef) {
363+
if (!shouldRunLinuxOnlyQa()) {
364+
console.log(
365+
`[turbo:qa] skip root qa:systemd-service-manager (linux only, current platform: ${process.platform})`,
366+
)
367+
return
368+
}
369+
355370
const pathspecs = ['scripts/bash/systemd-service-manager', 'package.json']
356371

357372
if (modeValue === 'all') {

scripts/qa.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { spawnSync } from 'node:child_process'
44
import { existsSync } from 'node:fs'
55
import { buildPnpmCommand } from './pnpm-command.mjs'
6+
import { shouldRunLinuxOnlyQa } from './qa-platform.mjs'
67

78
// 传统版 QA 编排器。
89
// 这个入口复用各 workspace 包自身定义的 `qa` 脚本,不依赖 Turbo 任务图;
@@ -378,6 +379,13 @@ function runRootPwshQa(modeValue, sinceRef) {
378379
}
379380

380381
function runRootFnosQa(modeValue, sinceRef) {
382+
if (!shouldRunLinuxOnlyQa()) {
383+
console.log(
384+
`[qa] skip root qa:fnos (linux only, current platform: ${process.platform})`,
385+
)
386+
return
387+
}
388+
381389
const fnosPathspecs = ['linux/fnos', 'package.json']
382390

383391
if (modeValue === 'all') {
@@ -396,6 +404,13 @@ function runRootFnosQa(modeValue, sinceRef) {
396404
}
397405

398406
function runRootSystemdServiceManagerQa(modeValue, sinceRef) {
407+
if (!shouldRunLinuxOnlyQa()) {
408+
console.log(
409+
`[qa] skip root qa:systemd-service-manager (linux only, current platform: ${process.platform})`,
410+
)
411+
return
412+
}
413+
399414
const pathspecs = ['scripts/bash/systemd-service-manager', 'package.json']
400415

401416
if (modeValue === 'all') {

0 commit comments

Comments
 (0)