Files
opsxshell/scripts/build-script.test.mjs
T
Logan.LiandCursor 9ce71795b8 feat: add terminal broadcast, context menu, and shell close
Complete multi-pane broadcast, standard terminal right-click actions, batch host selection with progress, and native ssh_close_shell so closing a pane tears down the remote shell.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-05 19:53:39 +08:00

55 lines
2.5 KiB
JavaScript

import assert from 'node:assert/strict'
import { spawnSync } from 'node:child_process'
import { mkdirSync, mkdtempSync, readFileSync, writeFileSync } from 'node:fs'
import test from 'node:test'
import { dirname, resolve } from 'node:path'
import { tmpdir } from 'node:os'
import { fileURLToPath } from 'node:url'
import { inspectVersions, setVersion } from './set-version.mjs'
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..')
test('build.sh is valid Bash and documents supported native targets', () => {
const syntax = spawnSync('bash', ['-n', 'build.sh'], { cwd: root, encoding: 'utf8' })
assert.equal(syntax.status, 0, syntax.stderr)
const help = spawnSync('bash', ['build.sh', '--help'], { cwd: root, encoding: 'utf8' })
assert.equal(help.status, 0, help.stderr)
assert.match(help.stdout, /mac-arm64/)
assert.match(help.stdout, /win-x64/)
assert.match(help.stdout, /不会创建或推送 Git tag/)
})
test('build.bat provides an equivalent native Windows x64 release path', () => {
const script = readFileSync(resolve(root, 'build.bat'), 'utf8')
assert.match(script, /x86_64-pc-windows-msvc/)
assert.match(script, /acceptance:full/)
assert.match(script, /release-preflight\.mjs windows/)
assert.match(script, /verify-release\.mjs windows/)
assert.match(script, /nsis\\\*\.exe/)
assert.match(script, /SHA256SUMS\.txt/)
assert.match(script, /不会创建或推送 Git tag/)
})
test('release metadata versions stay synchronized', () => {
const versions = Object.values(inspectVersions(root))
assert.ok(versions.length > 0)
assert.ok(
versions.every((version) => version === versions[0]),
JSON.stringify(versions)
)
})
test('version updater synchronizes every release metadata file', () => {
const fixture = mkdtempSync(resolve(tmpdir(), 'opsxshell-version-'))
mkdirSync(resolve(fixture, 'src-tauri'))
writeFileSync(resolve(fixture, 'package.json'), '{"version":"2.1.0"}\n')
writeFileSync(resolve(fixture, 'package-lock.json'), '{"version":"2.1.0","packages":{"":{"version":"2.1.0"}}}\n')
writeFileSync(resolve(fixture, 'src-tauri/tauri.conf.json'), '{"version":"2.1.0"}\n')
writeFileSync(resolve(fixture, 'src-tauri/Cargo.toml'), '[package]\nname = "opsxshell"\nversion = "2.1.0"\n')
writeFileSync(resolve(fixture, 'src-tauri/Cargo.lock'), '[[package]]\nname = "opsxshell"\nversion = "2.1.0"\n')
const versions = setVersion(fixture, '2.1.7')
assert.ok(Object.values(versions).every((version) => version === '2.1.7'))
})