Files
Strata/app/host/tests/powershell-utf8.test.mjs
T
Niko1221 4058aa782b Layout move for 0.2.16: the top level becomes app/, engine/, terminal/, docs/, tools/ and .github/
Made by tools/layout/move_0216.py (the commit before this one) on db8e0be9c, the final code head of 0.2.16:
- 75 git mv (renames, so `git log --follow` and blame keep working; packaging/acceptance_matrix.md shows as delete + add because its links
  changed too) and 3 removals: SETUP.bat, UPDATE.bat and update.sh (setup.py --update pulls the code now);
- 1,425 path edits in 307 files: root-relative paths in CI, Docker, .gitignore and the release scripts; Markdown links; Python and
  Node joins from a root that moved with its folder; explicit edits for code that computes a root or names a moved path; tables of
  repository paths inside tests.

engine/ holds what CMake builds (src, include, cmake, metal, sycl, spark, third_party, the C++ tests and benches). app/ is the desktop
app and its host (was apps/). terminal/ is the Terminal in the layout of the installed one (strata.py, setup.py, strata_cli,
strata_control, serve, bin, data, ref, crates, the Python tools and tests). docs/ has the documentation, docs/lang/ the translated
READMEs, docs/history and docs/bench-results. tools/ has the repository's own checks, packaging, docker, research and nix.
tests/core/test_tqp_ref.py is a pytest file and stays with the Python tests (terminal/tests/core/).
AGENTS.md, README.md, LICENSE, setup.sh and START-HERE.bat stay at the root.

No behaviour change: the same command lines, the same sources. For this head a replay of the script gave the same numbers and the path
scan (tools/layout/checks/path_scan.py) reports no hit; the suites and the builds run on this commit next.
2026-11-17 13:19:21 +01:00

27 lines
1.8 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { mkdtempSync, rmSync } from 'node:fs';
import { execFileSync } from 'node:child_process';
import { tmpdir } from 'node:os';
import { basename, join } from 'node:path';
import { POWERSHELL_UTF8, utf8Script } from '../server/powershell-utf8.mjs';
test('the UTF-8 line comes first and leaves the script alone', () => {
assert.equal(utf8Script('Get-Date'), POWERSHELL_UTF8 + 'Get-Date');
assert.match(POWERSHELL_UTF8, /^\[Console\]::OutputEncoding = New-Object System\.Text\.UTF8Encoding \$false;/);
});
// #3202: PowerShell writes to a pipe in the OEM code page (cp866 on a Russian Windows, cp437 elsewhere); a Cyrillic folder came back
// as mojibake or "?". The same happens on any non-UTF-8 OEM page, so this fails on this machine without the line, too.
test('a Cyrillic temp folder name survives PowerShell through a pipe', { skip: process.platform !== 'win32' && 'needs Windows PowerShell (Windows only)' }, t => {
const word = String.fromCharCode(0x414, 0x43e, 0x43a, 0x443, 0x43c, 0x435, 0x43d, 0x442, 0x44b); // "Документы"
const dir = mkdtempSync(join(tmpdir(), word + '-'));
t.after(() => rmSync(dir, { recursive: true, force: true }));
const read = script => execFileSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', script],
{ encoding: 'utf8', windowsHide: true, env: { ...process.env, STRATA_UTF8_TEST: dir } }).trim();
const ask = '(Get-Item -LiteralPath $env:STRATA_UTF8_TEST).FullName';
const name = path => basename(path.replaceAll('\\', '/')).toLowerCase(); // the temp folder may come back as a short 8.3 path
assert.equal(name(read(utf8Script(ask))), name(dir));
assert.equal(name(read(utf8Script(`[Console]::Out.Write((${ask}))`))), name(dir));
});