dsh-ris-ide 1.8.5 → 1.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/run-with-log.sh +28 -10
- package/lib/client.js +402 -111
- package/lib/index.js +224 -64
- package/lib/proxy-lifecycle.js +502 -0
- package/lib/proxy.js +50 -0
- package/lib/risd/server.js +144 -38
- package/lib/risd/ui.js +114 -23
- package/package.json +2 -2
- package/test/client-viewer.test.mjs +229 -31
- package/test/clipboard.test.mjs +41 -2
- package/test/host-tail.test.mjs +137 -1
- package/test/proxy-lifecycle.test.mjs +251 -0
- package/test/proxy.test.mjs +48 -0
- package/test/risd-api.test.mjs +4 -1
- package/test/risd-engine.test.mjs +45 -3
- package/test/risd-follow-start.test.mjs +3 -2
- package/test/risd-handoff.test.mjs +4 -2
- package/test/risd-helpers.mjs +23 -2
- package/test/risd-teardown.test.mjs +4 -2
- package/test/risd-ui.test.mjs +21 -2
|
@@ -190,11 +190,15 @@ test('one proxy control governs engine, interception and git together', async ()
|
|
|
190
190
|
const host = await readFile(new URL('../lib/index.js', import.meta.url), 'utf8')
|
|
191
191
|
// Start/stop drive all three layers, and so does the host exit hook. The UI that
|
|
192
192
|
// used to say so lives on the risd page now (the panel dialog is deleted).
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
assert.ok(host.includes('
|
|
193
|
+
// The service owns all three layers (lib/proxy-lifecycle.js): the route only hands
|
|
194
|
+
// it the cwd/host and the interactive flag of THIS click, and the lifecycle starts
|
|
195
|
+
// engine → interception → git. A 待启动 start arms a watcher instead.
|
|
196
|
+
assert.ok(host.includes('startProxyService({ cwd, gitHost, interactive, syncGit: (plan) => syncGitProxy(plan) })'), 'start brings all three layers up through the lifecycle (a local fallback keeps the click interactive)')
|
|
197
|
+
assert.ok(host.includes('stopProxyService({ cwd, gitHost, syncGit: (plan) => syncGitProxy(plan) })'), 'stop takes all three layers down through the lifecycle')
|
|
198
|
+
assert.ok(host.includes("if (outcome.phase === 'running') inheritedEngine = null"), 'only a running service clears the adopted-engine banner')
|
|
199
|
+
assert.ok(host.includes('syncGit: (plan) => syncGitProxy(plan)'), 'the lifecycle writes/clears the git entry through the host helper')
|
|
197
200
|
assert.ok(host.includes('clearGitProxySync()'), 'the exit hook undoes the git entry too')
|
|
201
|
+
assert.ok(host.includes('releaseProxyLifecycle()'), 'the exit hook ends a 待启动 wait too')
|
|
198
202
|
})
|
|
199
203
|
|
|
200
204
|
test('the console follows the live sidebar session, not the one it opened in', async () => {
|
|
@@ -1746,16 +1750,21 @@ test('the tree clipboard keys only fire while the tree owns the focus', async ()
|
|
|
1746
1750
|
})
|
|
1747
1751
|
|
|
1748
1752
|
// 1.6.10: Ctrl+C / Ctrl+X used to read the context-menu state only, so the
|
|
1749
|
-
// keyboard silently copied nothing. 1.6.11
|
|
1750
|
-
//
|
|
1753
|
+
// keyboard silently copied nothing. 1.6.11 made the tree a multi-selection.
|
|
1754
|
+
// 1.8.7: the menu and the keys now share ONE seed (the tree selection) and the
|
|
1755
|
+
// selection is narrowed first — expanding A and then Ctrl+clicking A/a、A/b used
|
|
1756
|
+
// to leave [A, A/a, A/b] on the clipboard, and the cut moved A wholesale.
|
|
1751
1757
|
test('Ctrl+C copies the selected rows without the context menu', async () => {
|
|
1752
1758
|
const { readFile } = await import('node:fs/promises')
|
|
1753
1759
|
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
1754
|
-
assert.match(source, /var seed =
|
|
1755
|
-
'the
|
|
1756
|
-
assert.
|
|
1757
|
-
'
|
|
1758
|
-
assert.match(source, /var
|
|
1760
|
+
assert.match(source, /var seed = selectedPath === null \? '' : selectedPath/,
|
|
1761
|
+
'the menu and the keys share the tree selection as their only seed')
|
|
1762
|
+
assert.doesNotMatch(source, /var seed = treeMenu !== null/,
|
|
1763
|
+
'a menu no longer carries a seed of its own')
|
|
1764
|
+
assert.match(source, /var picked = selectionFor\(seed\)/, 'a menu/key command expands to the whole selection')
|
|
1765
|
+
assert.match(source, /var paths = normalizeSelection\(picked\)/,
|
|
1766
|
+
'a covering folder is dropped before anything is copied or cut')
|
|
1767
|
+
assert.match(source, /noteNormalizedSelection\(picked, paths\)/, 'and the user is told what was skipped')
|
|
1759
1768
|
assert.match(source, /setClipboard\(\{ mode: mode, items: items \}\)/, 'the clipboard carries every selected row')
|
|
1760
1769
|
assert.match(source, /event\.key === 'a' \|\| event\.key === 'A'/, 'Ctrl+A is claimed while the tree owns the keys')
|
|
1761
1770
|
assert.match(source, /var visible = visibleEntries\(\)/, 'Ctrl+A selects the visible rows')
|
|
@@ -1832,9 +1841,10 @@ test('pasting several OS files never stops at the first existing name', async ()
|
|
|
1832
1841
|
// files AND the URI list are read together; a name delivered as both is imported once.
|
|
1833
1842
|
assert.match(source, /if \(files\.length > 0 \|\| paths\.length > 0\) \{/,
|
|
1834
1843
|
'a payload with files or paths goes through the tree paste path')
|
|
1835
|
-
assert.match(source, /void
|
|
1844
|
+
assert.match(source, /void pasteResolved\(dir, null, false\)/,
|
|
1836
1845
|
'an empty payload asks the Host what the OS clipboard holds')
|
|
1837
|
-
assert.match(source, /void
|
|
1846
|
+
assert.match(source, /void pasteResolved\(dir, \{ files: files, paths: paths \}, false\)/)
|
|
1847
|
+
assert.match(source, /function pasteResolved\(dir, payload, announce\) \{/, 'one decision function for both gestures')
|
|
1838
1848
|
assert.match(source, /if \(fileName === '' \|\| seen\[fileName\] === true\) continue/)
|
|
1839
1849
|
assert.match(source, /if \(leaf === '' \|\| seen\[leaf\] === true\) continue/)
|
|
1840
1850
|
})
|
|
@@ -1847,17 +1857,20 @@ test('pasting several OS files never stops at the first existing name', async ()
|
|
|
1847
1857
|
test('an OS clipboard paste wins over a stale tree clipboard', async () => {
|
|
1848
1858
|
const { readFile } = await import('node:fs/promises')
|
|
1849
1859
|
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
1850
|
-
// The keydown
|
|
1851
|
-
|
|
1852
|
-
'the tree clipboard no longer swallows Ctrl+V outright')
|
|
1860
|
+
// The keydown never claims the gesture by itself: it is only a fallback, and it
|
|
1861
|
+
// ends in the same decision function the context menu calls.
|
|
1853
1862
|
assert.match(source, /if \(isTextEntry\(event\.target\)\) return/, 'an editor keeps its native paste')
|
|
1854
|
-
// …it waits one beat, so an empty OS clipboard still pastes the tree clipboard.
|
|
1855
1863
|
assert.match(source, /var askedAt = Date\.now\(\)/)
|
|
1856
1864
|
assert.match(source, /if \(pasteAtRef\.current >= askedAt\) return/)
|
|
1865
|
+
assert.match(source, /void pasteResolved\(target, null, false\)/,
|
|
1866
|
+
'the 150ms fallback asks the shared rule, not the in-memory clipboard')
|
|
1857
1867
|
// The paste handler decides: our own copy keeps the tree semantics, anything else imports.
|
|
1858
1868
|
assert.match(source, /pasteAtRef\.current = Date\.now\(\)/, 'the paste event stands the fallback down')
|
|
1859
|
-
assert.match(source, /
|
|
1869
|
+
assert.match(source, /ownCopy: delivered && treeItems\.length > 0 && isTreeClipboardCopy\(files, paths\)/,
|
|
1860
1870
|
'our own copy is confirmed against the Host before it takes the tree path')
|
|
1871
|
+
assert.match(source, /var plan = pasteDecision\(\{/, 'both gestures ask one pure rule for the verdict')
|
|
1872
|
+
assert.match(source, /if \(delivered && input\.ownCopy !== true\) return 'external'/,
|
|
1873
|
+
'newer external content wins over the tree clipboard')
|
|
1861
1874
|
assert.match(source, /function isTreeClipboardCopy\(files, paths\) \{/)
|
|
1862
1875
|
assert.match(source, /function isTextEntry\(node\) \{/)
|
|
1863
1876
|
assert.match(source, /if \(own\.length === 0 \|\| seen\.length !== own\.length\) return false/,
|
|
@@ -1869,10 +1882,13 @@ test('an OS clipboard paste wins over a stale tree clipboard', async () => {
|
|
|
1869
1882
|
test('a newer OS clipboard discards the older tree clipboard', async () => {
|
|
1870
1883
|
const { readFile } = await import('node:fs/promises')
|
|
1871
1884
|
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
1872
|
-
assert.match(source,
|
|
1885
|
+
assert.match(source, /function pasteExternal\(dir, files, paths\) \{\n\s+if \(clipboard !== null\) setClipboard\(null\)\n\s+void importExternal\(dir, files, paths\)/,
|
|
1886
|
+
'importing external content drops the stale tree clipboard first')
|
|
1873
1887
|
assert.match(source, /已清空文件树里的旧复制/)
|
|
1874
|
-
assert.match(source, /
|
|
1875
|
-
|
|
1888
|
+
assert.match(source, /if \(!delivered && text\.trim\(\) !== ''\) return 'stale'/,
|
|
1889
|
+
'a text-only OS clipboard invalidates the in-memory copy')
|
|
1890
|
+
assert.match(source, /if \(hasClipboard\) return 'tree'/,
|
|
1891
|
+
'with nothing external readable, the tree clipboard still pastes')
|
|
1876
1892
|
})
|
|
1877
1893
|
|
|
1878
1894
|
// 桌面 → 文件树(WSL):Explorer 里的文件复制根本进不了 Chromium(WSLg 不桥接
|
|
@@ -1881,15 +1897,196 @@ test('a newer OS clipboard discards the older tree clipboard', async () => {
|
|
|
1881
1897
|
test('a desktop copy reaches the tree through the Host clipboard', async () => {
|
|
1882
1898
|
const { readFile } = await import('node:fs/promises')
|
|
1883
1899
|
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
1884
|
-
assert.match(source, /void
|
|
1900
|
+
assert.match(source, /void pasteResolved\(dir, null, false\)/, 'an empty payload asks the Host')
|
|
1885
1901
|
assert.match(source, /async function fsClipboardState\(scope\) \{[\s\S]{0,400}'dsh-ris-ide\/clipboard\/read'/)
|
|
1886
1902
|
assert.match(source, /var host = await readHostClipboard\(\)/)
|
|
1887
|
-
assert.match(source, /if \(
|
|
1903
|
+
assert.match(source, /if \(hasClipboard && samePathSet\(hostFiles, treePaths\)\) return 'tree'/,
|
|
1888
1904
|
'our own copy stays on the tree path')
|
|
1889
|
-
assert.match(source, /
|
|
1905
|
+
assert.match(source, /pasteExternal\(dir, files, host\.files\)/,
|
|
1890
1906
|
'files the page cannot see are imported from the Host list')
|
|
1891
|
-
assert.match(source, /function
|
|
1892
|
-
assert.match(source, /function
|
|
1907
|
+
assert.match(source, /function samePathSet\(left, right\) \{/)
|
|
1908
|
+
assert.match(source, /function trimPathSeparator\(path\) \{/, 'one separator rule at module scope')
|
|
1909
|
+
assert.match(source, /function trimTrailingSeparator\(path\) \{\n\s+return trimPathSeparator\(path\)/)
|
|
1910
|
+
})
|
|
1911
|
+
|
|
1912
|
+
// 1.8.7 (bug): 点开 A 会把 A 的行走一次 selectOne,再 Ctrl+点 a、b 只追加——
|
|
1913
|
+
// 选区成了 [A, A/a, A/b],于是「剪切 a、b」先整体搬走 A,再对已经不存在的
|
|
1914
|
+
// A/a、A/b 逐项失败,用户看到的是「整个 A 被剪切进 B」。归一化在命令边界
|
|
1915
|
+
// (复制/剪切/删除/拖动)按「后代优先」丢掉被覆盖的祖先,且只减不增。
|
|
1916
|
+
test('a covering folder never travels with the rows selected inside it', () => {
|
|
1917
|
+
const narrow = T.narrowSelection
|
|
1918
|
+
// The reported sequence: expand A (selects A), Ctrl+click both children.
|
|
1919
|
+
assert.deepEqual(narrow(['/w/A', '/w/A/a.txt', '/w/A/b.txt']), ['/w/A/a.txt', '/w/A/b.txt'])
|
|
1920
|
+
// A deeper chain keeps only the leaf the user pointed at.
|
|
1921
|
+
assert.deepEqual(narrow(['/w', '/w/A', '/w/A/x/y.txt']), ['/w/A/x/y.txt'])
|
|
1922
|
+
// Unrelated siblings, plain file lists and a lone folder survive untouched.
|
|
1923
|
+
assert.deepEqual(narrow(['/w/A/a.txt', '/w/B/c.txt']), ['/w/A/a.txt', '/w/B/c.txt'])
|
|
1924
|
+
assert.deepEqual(narrow(['/w/A']), ['/w/A'])
|
|
1925
|
+
// Same entry twice (with a trailing slash) collapses.
|
|
1926
|
+
assert.deepEqual(narrow(['/w/A/', '/w/A']), ['/w/A'])
|
|
1927
|
+
assert.deepEqual(narrow(['/w/A', '/w/A/', '/w/A/a']), ['/w/A/a'])
|
|
1928
|
+
// A shared name prefix is not containment: /w/AB is a sibling of /w/A.
|
|
1929
|
+
assert.deepEqual(narrow(['/w/A', '/w/AB']), ['/w/A', '/w/AB'])
|
|
1930
|
+
// Windows separators are honoured too (the host may be a Windows box).
|
|
1931
|
+
assert.deepEqual(narrow(['C:\\w\\A', 'C:\\w\\A\\a.txt']), ['C:\\w\\A\\a.txt'])
|
|
1932
|
+
assert.deepEqual(narrow([]), [])
|
|
1933
|
+
assert.deepEqual(narrow(undefined), [])
|
|
1934
|
+
// The rule only ever DROPS rows: a delete can never act on more than was shown.
|
|
1935
|
+
const input = ['/w/A', '/w/A/a', '/w/B', '/w/B/b']
|
|
1936
|
+
for (const path of narrow(input)) assert.ok(input.includes(path))
|
|
1937
|
+
})
|
|
1938
|
+
|
|
1939
|
+
test('path identity ignores order and trailing separators but not count', () => {
|
|
1940
|
+
assert.equal(T.samePathSet(['/w/b', '/w/a'], ['/w/a/', '/w/b']), true)
|
|
1941
|
+
assert.equal(T.samePathSet(['/w/a', '/w/a'], ['/w/a']), false, 'the same path twice is not a match')
|
|
1942
|
+
assert.equal(T.samePathSet(['/w/a'], ['/w/a', '/w/b']), false)
|
|
1943
|
+
assert.equal(T.samePathSet(['/w/A'], ['/w/AB']), false, 'a name prefix is not the same entry')
|
|
1944
|
+
assert.equal(T.samePathSet(null, ['/w/a']), false)
|
|
1945
|
+
assert.equal(T.samePathSet([], []), true)
|
|
1946
|
+
})
|
|
1947
|
+
|
|
1948
|
+
// 两个入口(右键菜单 / Ctrl+V)现在都问同一个纯函数;矩阵覆盖四种来源 ×
|
|
1949
|
+
// 能否读回系统剪贴板 × 页面是否投递了负载,每个组合只有一个正确答案。
|
|
1950
|
+
test('every clipboard combination resolves to one paste verdict', () => {
|
|
1951
|
+
const decide = T.pasteDecision
|
|
1952
|
+
const tree = ['/w/A/a.txt', '/w/A/b.txt']
|
|
1953
|
+
// Our own copy read back → tree semantics (a cut stays a MOVE).
|
|
1954
|
+
assert.equal(decide({ hostFiles: tree, treePaths: tree, hasClipboard: true }), 'tree')
|
|
1955
|
+
// Same entries, different order / trailing separators → still ours.
|
|
1956
|
+
assert.equal(decide({ hostFiles: ['/w/A/b.txt', '/w/A/a.txt/'], treePaths: tree, hasClipboard: true }), 'tree')
|
|
1957
|
+
// Other files on the clipboard → import them (the stale copy is dropped upstream).
|
|
1958
|
+
assert.equal(decide({ hostFiles: ['/w/desk/x.txt'], treePaths: tree, hasClipboard: true }), 'import')
|
|
1959
|
+
// Other files with no tree clipboard → still an import.
|
|
1960
|
+
assert.equal(decide({ hostFiles: ['/w/desk/x.txt'], treePaths: [], hasClipboard: false }), 'import')
|
|
1961
|
+
// A payload that is not our copy is external even when the Host is unreadable.
|
|
1962
|
+
assert.equal(decide({ delivered: true, ownCopy: false, hostFiles: [], treePaths: tree, hasClipboard: true }), 'external')
|
|
1963
|
+
// An unreadable Host plus our own payload → the tree clipboard still pastes.
|
|
1964
|
+
assert.equal(decide({ delivered: true, ownCopy: true, hostFiles: [], treePaths: tree, hasClipboard: true }), 'tree')
|
|
1965
|
+
// Text only → the in-memory file copy is stale.
|
|
1966
|
+
assert.equal(decide({ hostFiles: [], treePaths: tree, hostText: 'hello', hasClipboard: true }), 'stale')
|
|
1967
|
+
// A text flavour next to a real file list never wins.
|
|
1968
|
+
assert.equal(decide({ hostFiles: ['/w/x.txt'], treePaths: [], hostText: 'hello', hasClipboard: false }), 'import')
|
|
1969
|
+
// Empty everything → nothing; the menu says so, Ctrl+V stays silent.
|
|
1970
|
+
assert.equal(decide({}), 'nothing')
|
|
1971
|
+
assert.equal(decide({ hasClipboard: true }), 'nothing')
|
|
1972
|
+
assert.equal(decide({ delivered: true, ownCopy: false, hostFiles: [], treePaths: [], hasClipboard: false }), 'external')
|
|
1973
|
+
// A remembered clipboard is required, not just remembered paths.
|
|
1974
|
+
assert.equal(decide({ hostFiles: [], treePaths: tree, hasClipboard: false }), 'nothing')
|
|
1975
|
+
})
|
|
1976
|
+
|
|
1977
|
+
// The menu used to be disabled whenever the in-memory clipboard was empty, so a
|
|
1978
|
+
// desktop copy could only be pasted with Ctrl+V. It now asks the Host too, and
|
|
1979
|
+
// both entry points run pasteResolved() — the menu never pastes what Ctrl+V would not.
|
|
1980
|
+
test('the context menu can paste an OS clipboard copy', async () => {
|
|
1981
|
+
const { readFile } = await import('node:fs/promises')
|
|
1982
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
1983
|
+
assert.match(source, /var canPaste = clipboard !== null \|\| osPaste\.state === 'files'/)
|
|
1984
|
+
assert.match(source, /var \[osPaste, setOsPaste\] = useState\(\{ state: 'idle', count: 0 \}\)/)
|
|
1985
|
+
assert.match(source, /readHostClipboardCached\(\)/, 'opening the menu reads the Host behind a short cache')
|
|
1986
|
+
assert.match(source, /'粘贴 ' \+ osPaste\.count \+ ' 项(来自系统剪贴板)到 '/)
|
|
1987
|
+
assert.match(source, /void pasteResolved\(dir, null, true\)/, 'the menu runs the shared rule with announce')
|
|
1988
|
+
assert.doesNotMatch(source, /disabled: clipboard === null/, 'the menu no longer treats an empty tree clipboard as empty everything')
|
|
1989
|
+
})
|
|
1990
|
+
|
|
1991
|
+
// 2 (bug): a drag only fires events while the pointer moves, so a folder that is
|
|
1992
|
+
// scrolled out of view could never be dropped on. The row and the blank area both
|
|
1993
|
+
// arm a rAF loop that scrolls near the edges and carries the drop target along.
|
|
1994
|
+
// TASK 1 acceptance, against the REAL move route: 「选中 A 下 a、b,剪切,粘到 B」
|
|
1995
|
+
// used to move A itself, because both the row click that expanded A and the
|
|
1996
|
+
// Ctrl+clicks on a/b were in the selection. The selection is normalized now;
|
|
1997
|
+
// this test proves the Host accepts exactly the narrowed items and that A stays.
|
|
1998
|
+
test('cutting a folder with its children selected moves only the children', async () => {
|
|
1999
|
+
const { mkdtemp, mkdir, writeFile, readdir } = await import('node:fs/promises')
|
|
2000
|
+
const { tmpdir } = await import('node:os')
|
|
2001
|
+
const { join } = await import('node:path')
|
|
2002
|
+
const { Readable } = await import('node:stream')
|
|
2003
|
+
const root = await mkdtemp(join(tmpdir(), 'dsh-cut-children-'))
|
|
2004
|
+
const A = join(root, 'A')
|
|
2005
|
+
const B = join(root, 'B')
|
|
2006
|
+
await mkdir(A, { recursive: true })
|
|
2007
|
+
await mkdir(B, { recursive: true })
|
|
2008
|
+
await writeFile(join(A, 'a.txt'), 'a', 'utf8')
|
|
2009
|
+
await writeFile(join(A, 'b.txt'), 'b', 'utf8')
|
|
2010
|
+
|
|
2011
|
+
const selection = [A, join(A, 'a.txt'), join(A, 'b.txt')]
|
|
2012
|
+
const items = T.narrowSelection(selection)
|
|
2013
|
+
assert.deepEqual(items, [join(A, 'a.txt'), join(A, 'b.txt')], 'the covering folder is not cut')
|
|
2014
|
+
|
|
2015
|
+
for (const from of items) {
|
|
2016
|
+
const name = from.slice(from.lastIndexOf('/') + 1)
|
|
2017
|
+
const req = Object.assign(Readable.from([JSON.stringify({ sessionId: 'session-1', from: from, toDir: B, name: name })]), {
|
|
2018
|
+
method: 'POST',
|
|
2019
|
+
url: hostTest.FS_MOVE_PATH,
|
|
2020
|
+
headers: { host: '127.0.0.1:3080' },
|
|
2021
|
+
})
|
|
2022
|
+
const res = {
|
|
2023
|
+
status: 0,
|
|
2024
|
+
text: '',
|
|
2025
|
+
writeHead(status) { this.status = status },
|
|
2026
|
+
write(chunk) { if (chunk !== undefined && chunk !== null) this.text += chunk.toString() },
|
|
2027
|
+
end(chunk) { this.write(chunk) },
|
|
2028
|
+
on() {},
|
|
2029
|
+
}
|
|
2030
|
+
await hostTest.serveFsOp({ sessions: { get: () => ({ header: { cwd: root } }) } }, req, res, {})
|
|
2031
|
+
assert.equal(res.status, 200, 'move ' + name + ': ' + res.text)
|
|
2032
|
+
}
|
|
2033
|
+
assert.deepEqual((await readdir(A)).sort(), [], 'A itself was not moved, just emptied')
|
|
2034
|
+
assert.deepEqual((await readdir(B)).sort(), ['a.txt', 'b.txt'], 'both files landed in B')
|
|
2035
|
+
})
|
|
2036
|
+
|
|
2037
|
+
// The copy half of the same report (m00079 「剪切和复制都检查一下」): a copy of
|
|
2038
|
+
// [A, A/a, A/b] must duplicate the two FILES into B and leave A untouched, never
|
|
2039
|
+
// clone the whole folder.
|
|
2040
|
+
test('copying a folder with its children selected copies only the children', async () => {
|
|
2041
|
+
const { mkdtemp, mkdir, writeFile, readdir, readFile } = await import('node:fs/promises')
|
|
2042
|
+
const { tmpdir } = await import('node:os')
|
|
2043
|
+
const { join } = await import('node:path')
|
|
2044
|
+
const { Readable } = await import('node:stream')
|
|
2045
|
+
const root = await mkdtemp(join(tmpdir(), 'dsh-copy-children-'))
|
|
2046
|
+
const A = join(root, 'A')
|
|
2047
|
+
const B = join(root, 'B')
|
|
2048
|
+
await mkdir(A, { recursive: true })
|
|
2049
|
+
await mkdir(B, { recursive: true })
|
|
2050
|
+
await writeFile(join(A, 'a.txt'), 'a', 'utf8')
|
|
2051
|
+
await writeFile(join(A, 'b.txt'), 'b', 'utf8')
|
|
2052
|
+
|
|
2053
|
+
const items = T.narrowSelection([A, join(A, 'a.txt'), join(A, 'b.txt')])
|
|
2054
|
+
assert.deepEqual(items, [join(A, 'a.txt'), join(A, 'b.txt')], 'the covering folder is not copied')
|
|
2055
|
+
for (const from of items) {
|
|
2056
|
+
const name = from.slice(from.lastIndexOf('/') + 1)
|
|
2057
|
+
const req = Object.assign(Readable.from([JSON.stringify({ sessionId: 'session-1', from: from, toDir: B, name: name })]), {
|
|
2058
|
+
method: 'POST', url: hostTest.FS_COPY_PATH, headers: { host: '127.0.0.1:3080' },
|
|
2059
|
+
})
|
|
2060
|
+
const res = {
|
|
2061
|
+
status: 0, text: '',
|
|
2062
|
+
writeHead(status) { this.status = status },
|
|
2063
|
+
write(chunk) { if (chunk !== undefined && chunk !== null) this.text += chunk.toString() },
|
|
2064
|
+
end(chunk) { this.write(chunk) },
|
|
2065
|
+
on() {},
|
|
2066
|
+
}
|
|
2067
|
+
await hostTest.serveFsOp({ sessions: { get: () => ({ header: { cwd: root } }) } }, req, res, {})
|
|
2068
|
+
assert.equal(res.status, 200, 'copy ' + name + ': ' + res.text)
|
|
2069
|
+
}
|
|
2070
|
+
assert.deepEqual((await readdir(A)).sort(), ['a.txt', 'b.txt'], 'A keeps its files')
|
|
2071
|
+
assert.deepEqual((await readdir(B)).sort(), ['a.txt', 'b.txt'], 'B receives the two files')
|
|
2072
|
+
assert.equal(await readFile(join(B, 'a.txt'), 'utf8'), 'a', 'contents travel')
|
|
2073
|
+
})
|
|
2074
|
+
|
|
2075
|
+
test('a drag near the tree edge scrolls the list', async () => {
|
|
2076
|
+
const { readFile } = await import('node:fs/promises')
|
|
2077
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
2078
|
+
assert.match(source, /function dragEdgeStep\(distance, edge\) \{/)
|
|
2079
|
+
assert.match(source, /function runDragAutoScroll\(\) \{/)
|
|
2080
|
+
assert.match(source, /function armDragAutoScroll\(event\) \{/)
|
|
2081
|
+
assert.match(source, /function stopDragAutoScroll\(\) \{/)
|
|
2082
|
+
assert.match(source, /requestAnimationFrame\(runDragAutoScroll\)/, 'the loop reschedules itself per frame')
|
|
2083
|
+
assert.match(source, /cancelAnimationFrame\(dragFrameRef\.current\)/, 'leaving or dropping stops it')
|
|
2084
|
+
assert.match(source, /rowAtEdge\(list, list\.scrollTop \+ fromTop\)/, 'the drop target follows the rows as they move')
|
|
2085
|
+
// The scroll watchdog [lastGoodTop] snaps back any scroll it cannot attribute to
|
|
2086
|
+
// the user (a drag has no pointerdown), so every frame must vouch for itself.
|
|
2087
|
+
assert.match(source, /markUserInput\(\)\n\s+list\.scrollTop = Math\.max\(0, Math\.min\(maxTop, list\.scrollTop \+ delta\)\)\n\s+rememberTop\(list\.scrollTop\)/)
|
|
2088
|
+
assert.match(source, /onDragOver: function \(event\) \{[^}]*armDragAutoScroll\(event\)/, 'rows and the container both arm it')
|
|
2089
|
+
assert.match(source, /onDragEnd: function \(\) \{ stopDragAutoScroll\(\) \}/, 'a finished drag stops it')
|
|
1893
2090
|
})
|
|
1894
2091
|
|
|
1895
2092
|
// 系统剪贴板只投递 `text/uri-list`(没有 File blob)时走 `/fs/import`:宿主读的是
|
|
@@ -3602,11 +3799,12 @@ test('only a FRONTEND row offers the browser button, and only a yds project prom
|
|
|
3602
3799
|
assert.match(source, /event\.stopPropagation\(\); openSite\(program\)/)
|
|
3603
3800
|
// Errors are told in the panel's note bar, never swallowed.
|
|
3604
3801
|
assert.match(source, /还没有可打开的地址|这个程序还没有\.\.\./)
|
|
3605
|
-
// The
|
|
3606
|
-
// never read "yds" (m04354).
|
|
3802
|
+
// The yds sentence may only appear behind the yds flag: a plain workspace must
|
|
3803
|
+
// never read "yds" (m04354). It promises the debugging browser now — the 🌐 button
|
|
3804
|
+
// no longer just opens the dev-server page for a yds front-end.
|
|
3607
3805
|
assert.match(source, /async function requestYdsProject\(scope\)/)
|
|
3608
3806
|
assert.match(source, /dsh-ris-yds\/probe\?/)
|
|
3609
|
-
assert.match(source, /ydsProject \? '(yds
|
|
3807
|
+
assert.match(source, /ydsProject \? '(yds 项目:点 🌐 用专用调试浏览器打开工作台,模块由扩展指向本地 dev server)' : ''/)
|
|
3610
3808
|
assert.doesNotMatch(source, /yds 项目会自动注入 YYCToken/, 'the old unconditional yds wording is gone')
|
|
3611
3809
|
})
|
|
3612
3810
|
|
|
@@ -3650,12 +3848,12 @@ test('the IDE console opens a frontend page with the same 🌐 as the sidebar (m
|
|
|
3650
3848
|
assert.match(busyTag, /disabled=""/)
|
|
3651
3849
|
assert.match(busy, /…<\/button>/)
|
|
3652
3850
|
|
|
3653
|
-
// The
|
|
3851
|
+
// The yds sentence only appears for a yds workspace (m04354).
|
|
3654
3852
|
const yds = renderWorkbench({
|
|
3655
3853
|
ydsProject: true,
|
|
3656
3854
|
programs: [{ id: 'frontend:ui#dev', name: 'ris-ui-3', kind: 'frontend', logPath: '/w/logs/ui.log', running: { alive: true } }],
|
|
3657
3855
|
})
|
|
3658
|
-
assert.match(yds, /yds
|
|
3856
|
+
assert.match(yds, /yds 项目:点 🌐 用专用调试浏览器打开工作台/)
|
|
3659
3857
|
})
|
|
3660
3858
|
|
|
3661
3859
|
test('the tab strip shows ⟳ while the buffer is clean and ± once it is dirty (m00388/m00808)', { skip: !reactIsReal ? 'React unavailable for SSR' : false }, () => {
|
package/test/clipboard.test.mjs
CHANGED
|
@@ -30,6 +30,7 @@ const {
|
|
|
30
30
|
stageClipboardCopy,
|
|
31
31
|
pruneClipboardStage,
|
|
32
32
|
clipboardStageMapping,
|
|
33
|
+
clipboardStageMappingFor,
|
|
33
34
|
verifyClipboardStageOriginals,
|
|
34
35
|
CLIPBOARD_STAGE_INTEGRITY_LOG,
|
|
35
36
|
windowsClipboardScript,
|
|
@@ -227,13 +228,51 @@ test('a COPY is published from a hidden staging area, never from the originals',
|
|
|
227
228
|
assert.ok(batches.length <= 3, 'only the recent batches survive')
|
|
228
229
|
})
|
|
229
230
|
|
|
231
|
+
// 1.8.7: a tree copy in workspace A stays on the OS clipboard after the user
|
|
232
|
+
// switches to workspace B. The read used to translate staged paths with B's
|
|
233
|
+
// manifest — A's staged path came back unchanged, so Ctrl+V treated our own copy
|
|
234
|
+
// as external content, imported the mirror and dropped the clipboard (a cut was
|
|
235
|
+
// downgraded to a copy without a word).
|
|
236
|
+
test('a staged copy maps back even after the user switches workspace', async () => {
|
|
237
|
+
const { mkdtemp, mkdir, writeFile } = await import('node:fs/promises')
|
|
238
|
+
const { tmpdir } = await import('node:os')
|
|
239
|
+
const { join } = await import('node:path')
|
|
240
|
+
const left = await mkdtemp(join(tmpdir(), 'dsh-clip-a-'))
|
|
241
|
+
const right = await mkdtemp(join(tmpdir(), 'dsh-clip-b-'))
|
|
242
|
+
await mkdir(right, { recursive: true })
|
|
243
|
+
const file = join(left, 'note.txt')
|
|
244
|
+
await writeFile(file, 'note', 'utf8')
|
|
245
|
+
const stage = await stageClipboardCopy(left, [file])
|
|
246
|
+
assert.notEqual(stage, null)
|
|
247
|
+
const staged = stage.staged[0]
|
|
248
|
+
|
|
249
|
+
const mapping = await clipboardStageMappingFor([staged])
|
|
250
|
+
assert.equal(mapping.get(staged), file, 'the staged path translates back from its own manifest')
|
|
251
|
+
|
|
252
|
+
// The old, root-keyed mapping only knew the CURRENT workspace: B has no batch.
|
|
253
|
+
const byRoot = await clipboardStageMapping(right)
|
|
254
|
+
assert.equal(byRoot.size, 0, 'B cannot map A\'s batch — which is why the key changed')
|
|
255
|
+
|
|
256
|
+
// Ordinary paths (a cut publishes real ones) are left alone.
|
|
257
|
+
const plain = await clipboardStageMappingFor([file, join(right, 'x.txt')])
|
|
258
|
+
assert.equal(plain.size, 0)
|
|
259
|
+
assert.equal(await clipboardStageMappingFor([]).then((table) => table.size), 0)
|
|
260
|
+
})
|
|
261
|
+
|
|
230
262
|
test('only a COPY is staged; a cut still publishes the real file', async () => {
|
|
231
263
|
const source = await readFile(new URL('../lib/index.js', import.meta.url), 'utf8')
|
|
232
264
|
assert.match(source, /if \(body\.cut !== true\) \{[\s\S]{0,600}stageClipboardCopy\(root, paths\)/,
|
|
233
265
|
'copy goes through the staging area')
|
|
234
266
|
assert.match(source, /published = stage\.staged/, 'the clipboard gets the staged paths, not the originals')
|
|
235
|
-
|
|
236
|
-
|
|
267
|
+
// The translation is keyed by the STAGED PATH ITSELF: the OS clipboard outlives a
|
|
268
|
+
// workspace switch, so a read must not depend on the root that is current now.
|
|
269
|
+
assert.match(source, /const mapping = await clipboardStageMappingFor\(files\)/,
|
|
270
|
+
'a read translates staged paths back without assuming the current workspace')
|
|
271
|
+
assert.match(source, /files = files\.map\(\(path\) => mapping\.get\(resolve\(path\)\) \?\? path\)/)
|
|
272
|
+
// A CUT publish leaves real paths behind; once they are gone the page must not
|
|
273
|
+
// be handed a ghost selection.
|
|
274
|
+
assert.match(source, /if \(info === undefined\) missing\.push\(path\)/, 'a vanished clipboard path is reported, not pasted')
|
|
275
|
+
assert.match(source, /warnings, missing \}\)/, 'the read answer carries what disappeared')
|
|
237
276
|
assert.match(source, /if \(dirent\.name === IDE_STATE_DIR\) continue/, 'the state folder (trash/cache/stage) is never a tree row')
|
|
238
277
|
assert.match(source, /'\.dsh-ris-ide',/, 'the watcher ignores its churn')
|
|
239
278
|
})
|
package/test/host-tail.test.mjs
CHANGED
|
@@ -675,7 +675,16 @@ test('platform classes resolve from the JDK itself when no jar carries them (m05
|
|
|
675
675
|
const resolved = await __test.resolveJdkSource(workspace, 'java.lang.annotation.ElementType')
|
|
676
676
|
assert.ok(resolved !== undefined, 'javap (or a JDK src.zip) answers for a platform class')
|
|
677
677
|
const text = await readFile(resolved.path, 'utf8')
|
|
678
|
-
|
|
678
|
+
// Two legitimate answers: a src.zip entry (a .java file: package + simple name,
|
|
679
|
+
// the dotted FQN never appears literally) or `javap` output (which prints it).
|
|
680
|
+
// Asserting the dotted name unconditionally only passed when the JDK had no
|
|
681
|
+
// src.zip, i.e. it failed on a pod whose JDK ships one.
|
|
682
|
+
if (resolved.kind === 'sources') {
|
|
683
|
+
assert.match(text, /package\s+java\.lang\.annotation;/, 'the source file is the right package')
|
|
684
|
+
assert.match(text, /(class|interface|@interface|enum)\s+ElementType/, 'the source file carries the class')
|
|
685
|
+
} else {
|
|
686
|
+
assert.match(text, /java\.lang\.annotation\.ElementType/, 'the javap dump carries the class')
|
|
687
|
+
}
|
|
679
688
|
// The same path without any module directory (a class clicked in a module that
|
|
680
689
|
// was never started through the IDE has no program log to name).
|
|
681
690
|
const viaEmptyDirs = await __test.resolveDependencySourceIn(workspace, [], 'java.lang.annotation.ElementType')
|
|
@@ -686,6 +695,38 @@ test('platform classes resolve from the JDK itself when no jar carries them (m05
|
|
|
686
695
|
}
|
|
687
696
|
})
|
|
688
697
|
|
|
698
|
+
test('a JDK that ships src.zip resolves to the .java source, not javap (m05797)', async () => {
|
|
699
|
+
// Deterministic on any machine: fabricate a JDK whose lib/src.zip has the
|
|
700
|
+
// modular layout real JDKs use (java.base/java/lang/annotation/...), so the
|
|
701
|
+
// `sources` branch is exercised even where the local JDK has no usable src.zip.
|
|
702
|
+
const workspace = await mkdtemp(join(tmpdir(), 'dsh-ris-ide-jdk-src-'))
|
|
703
|
+
const jdk = await mkdtemp(join(tmpdir(), 'dsh-ris-ide-fakejdk-'))
|
|
704
|
+
const previous = process.env.JAVA_HOME
|
|
705
|
+
try {
|
|
706
|
+
await mkdir(join(jdk, 'lib'), { recursive: true })
|
|
707
|
+
await writeFile(join(jdk, 'lib', 'src.zip'), buildZip([{
|
|
708
|
+
name: 'java.base/java/lang/annotation/ElementType.java',
|
|
709
|
+
data: '/* Copyright (c) 2003, 2025, Oracle and/or its affiliates. */\n'
|
|
710
|
+
+ 'package java.lang.annotation;\n\n'
|
|
711
|
+
+ '/** The constants of this enumerated class ... */\n'
|
|
712
|
+
+ 'public enum ElementType {\n TYPE,\n FIELD\n}\n',
|
|
713
|
+
}]))
|
|
714
|
+
process.env.JAVA_HOME = jdk
|
|
715
|
+
const resolved = await __test.resolveJdkSource(workspace, 'java.lang.annotation.ElementType')
|
|
716
|
+
assert.ok(resolved !== undefined, 'the src.zip answers for a platform class')
|
|
717
|
+
assert.equal(resolved.kind, 'sources', 'src.zip wins over javap')
|
|
718
|
+
const text = await readFile(resolved.path, 'utf8')
|
|
719
|
+
assert.match(text, /package\s+java\.lang\.annotation;/, 'the source carries its package')
|
|
720
|
+
assert.match(text, /(class|interface|@interface|enum)\s+ElementType/, 'the source carries the class')
|
|
721
|
+
assert.doesNotMatch(text, /Compiled from "ElementType\.java"/, 'this is not a javap dump')
|
|
722
|
+
} finally {
|
|
723
|
+
if (previous === undefined) delete process.env.JAVA_HOME
|
|
724
|
+
else process.env.JAVA_HOME = previous
|
|
725
|
+
await rm(workspace, { recursive: true, force: true })
|
|
726
|
+
await rm(jdk, { recursive: true, force: true })
|
|
727
|
+
}
|
|
728
|
+
})
|
|
729
|
+
|
|
689
730
|
test('the open-target route resolves a program by id and never invents a URL (m03945)', async () => {
|
|
690
731
|
const { root } = await makeProgramFixture()
|
|
691
732
|
await withServer(async ({ base }) => {
|
|
@@ -708,6 +749,72 @@ test('the open-target route resolves a program by id and never invents a URL (m0
|
|
|
708
749
|
}, undefined, root)
|
|
709
750
|
})
|
|
710
751
|
|
|
752
|
+
test('a yds front-end opens yds\' debugging browser, never a tab at the dev URL', async () => {
|
|
753
|
+
// The 🌐 answer for a yds front-end is NOT its dev server: the platform page is the
|
|
754
|
+
// workbench, and only yds' own browser carries the extension that points the module
|
|
755
|
+
// at the local dev server. ris-ide asks for `mode:'debug'` and passes the log's URL
|
|
756
|
+
// along as the live dev port — it must not window.open it.
|
|
757
|
+
const { root } = await makeProgramFixture()
|
|
758
|
+
const ctx = { sessions: { get: (id) => (id === 's1' ? { header: { cwd: root } } : undefined) } }
|
|
759
|
+
const calls = []
|
|
760
|
+
const state = { refuse: false }
|
|
761
|
+
const answer = (res, payload) => {
|
|
762
|
+
res.writeHead(200, { 'content-type': 'application/json' })
|
|
763
|
+
res.end(JSON.stringify(payload))
|
|
764
|
+
}
|
|
765
|
+
const server = createServer((req, res) => {
|
|
766
|
+
const url = new URL(req.url ?? '/', 'http://dsh.internal')
|
|
767
|
+
if (url.pathname === '/dsh-ris-yds/probe') {
|
|
768
|
+
answer(res, { ok: true, yds: true, projectDir: join(root, 'proj-a'), frontends: ['ui'] })
|
|
769
|
+
return
|
|
770
|
+
}
|
|
771
|
+
if (url.pathname === '/dsh-ris-yds/open') {
|
|
772
|
+
const chunks = []
|
|
773
|
+
req.on('data', (chunk) => chunks.push(chunk))
|
|
774
|
+
req.on('end', () => {
|
|
775
|
+
const body = JSON.parse(Buffer.concat(chunks).toString('utf8'))
|
|
776
|
+
calls.push(body)
|
|
777
|
+
if (state.refuse) answer(res, { ok: false, code: 'not-yds-frontend', reason: '不是这个前端' })
|
|
778
|
+
else answer(res, { ok: true, mode: 'debug', pid: 4242, port: 9222, url: 'https://workbench.example/c-ass-kk-hans' })
|
|
779
|
+
})
|
|
780
|
+
return
|
|
781
|
+
}
|
|
782
|
+
handleRequest(ctx, req, res, { maxBytes: HARD_MAX_BYTES, restrictToCwd: false, stopGraceMs: 5000 })
|
|
783
|
+
})
|
|
784
|
+
await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve))
|
|
785
|
+
const base = `http://127.0.0.1:${server.address().port}`
|
|
786
|
+
try {
|
|
787
|
+
const listing = await (await fetch(`${base}${PROGRAMS_PATH}?sessionId=s1&refresh=1`)).json()
|
|
788
|
+
const program = listing.programs.find((entry) => entry.kind === 'frontend')
|
|
789
|
+
assert.ok(program !== undefined, 'the fixture frontend program is discovered')
|
|
790
|
+
await mkdir(join(root, 'logs'), { recursive: true })
|
|
791
|
+
await writeFile(program.logPath, ' \u001b[32m- Local:\u001b[39m http://localhost:5173/\n')
|
|
792
|
+
|
|
793
|
+
const opened = await (await fetch(`${base}${OPEN_TARGET_PATH}?sessionId=s1&id=${encodeURIComponent(program.id)}`)).json()
|
|
794
|
+
assert.equal(opened.ok, true, JSON.stringify(opened))
|
|
795
|
+
assert.equal(opened.mode, 'debug', 'yds started its own browser')
|
|
796
|
+
assert.equal(opened.source, 'yds')
|
|
797
|
+
assert.equal(opened.pid, 4242)
|
|
798
|
+
assert.equal(opened.url, 'https://workbench.example/c-ass-kk-hans')
|
|
799
|
+
assert.equal(calls.length, 1)
|
|
800
|
+
assert.equal(calls[0].mode, 'debug', 'a yds front-end is never asked for the proxy page')
|
|
801
|
+
assert.equal(calls[0].workspace, root)
|
|
802
|
+
assert.equal(calls[0].frontend.code, 'ui')
|
|
803
|
+
assert.equal(calls[0].devUrl, 'http://localhost:5173/', 'the live dev URL travels along as a port hint')
|
|
804
|
+
|
|
805
|
+
// A refusal is reported, not papered over with a window at the dev URL.
|
|
806
|
+
state.refuse = true
|
|
807
|
+
const refused = await (await fetch(`${base}${OPEN_TARGET_PATH}?sessionId=s1&id=${encodeURIComponent(program.id)}`)).json()
|
|
808
|
+
assert.equal(refused.ok, false, 'a refusal is not turned into a silent window')
|
|
809
|
+
assert.equal(refused.code, 'not-yds-frontend')
|
|
810
|
+
assert.match(refused.message, /不是这个前端/)
|
|
811
|
+
assert.equal(calls.length, 2)
|
|
812
|
+
} finally {
|
|
813
|
+
await new Promise((resolve) => server.close(resolve))
|
|
814
|
+
await rm(root, { recursive: true, force: true })
|
|
815
|
+
}
|
|
816
|
+
})
|
|
817
|
+
|
|
711
818
|
test('a dev-server URL is read from local hosts, placeholders and ANSI logs (m03945)', async () => {
|
|
712
819
|
// What scaffolds actually print: webpack/vite use localhost, MDF prints
|
|
713
820
|
// `Node服务地址:http://<HOST地址>:3003`, and colour codes wrap both the label
|
|
@@ -718,6 +825,13 @@ test('a dev-server URL is read from local hosts, placeholders and ANSI logs (m03
|
|
|
718
825
|
['\u001b[32m - Local: \u001b[36mhttp://0.0.0.0:8080/\u001b[39m\n', 'http://127.0.0.1:8080/'],
|
|
719
826
|
['http://[::]:9000/\n', 'http://127.0.0.1:9000/'],
|
|
720
827
|
['Java服务地址:https://srmdev.hanslaser.com/c-ass-kk-hans\n', undefined],
|
|
828
|
+
// The LAST URL in a log is usually quoted from a failed request; the address is
|
|
829
|
+
// the one a server line announced (mftm: mdf-node prints no bare `Local:` line).
|
|
830
|
+
[' - Local: http://localhost:5173/\nERROR fetch http://127.0.0.1:3003/api/x.json\n', 'http://localhost:5173/'],
|
|
831
|
+
['Node服务地址:http://<HOST地址>:3003 当前环境:daily\nERROR Unable to fetch http://127.0.0.1:3003/}/c-ass-kk-hans/version.json\n', 'http://127.0.0.1:3003'],
|
|
832
|
+
// A URL with an unresolved template is not an address: opening it lands on a 404.
|
|
833
|
+
['GET http://127.0.0.1:3003/}/c-ass-kk-hans/version.json\n', undefined],
|
|
834
|
+
['\u001b[32mready in 512 ms\u001b[39m\n\u001b[36m➜\u001b[39m http://127.0.0.1:3004/\n', 'http://127.0.0.1:3004/'],
|
|
721
835
|
]
|
|
722
836
|
const dir = await mkdtemp(join(tmpdir(), 'ris-logurl-'))
|
|
723
837
|
const logPath = join(dir, 'prog.log')
|
|
@@ -3252,3 +3366,25 @@ test('a same-named row of another kind is not taken over by an update', () => {
|
|
|
3252
3366
|
assert.equal(merged.programs[0].startCommand, undefined, 'the frontend row keeps its own launch path')
|
|
3253
3367
|
assert.equal(merged.programs[1].startCommand, 'node x/bin/yds.js start')
|
|
3254
3368
|
})
|
|
3369
|
+
|
|
3370
|
+
test('a pidfile with no recorded grace falls back to the caller, not to one second', async () => {
|
|
3371
|
+
const dir = await mkdtemp(join(tmpdir(), 'dsh-ris-ide-grace-'))
|
|
3372
|
+
const log = join(dir, 'grace.log')
|
|
3373
|
+
try {
|
|
3374
|
+
// Every wrapper writes the 4th field, empty when the program asked for nothing.
|
|
3375
|
+
// Number('') === 0 and clampBytes floors at 1 KiB, so parsing it as zero used to
|
|
3376
|
+
// give a one-second TERM→KILL window: the wrapper was killed before it could
|
|
3377
|
+
// trap and write its exit banner (CI flake under load).
|
|
3378
|
+
await writeFile(`${log}${PID_SUFFIX}`, '1234 1235 1700000000000 \n')
|
|
3379
|
+
const record = await __test.readPidFile(log)
|
|
3380
|
+
assert.equal(record.graceMs, undefined, 'an empty field means "not recorded"')
|
|
3381
|
+
// A real value is still honored verbatim.
|
|
3382
|
+
await writeFile(`${log}${PID_SUFFIX}`, '1234 1235 1700000000000 2000\n')
|
|
3383
|
+
assert.equal((await __test.readPidFile(log)).graceMs, 2000)
|
|
3384
|
+
// Garbage in the optional field is not a grace either.
|
|
3385
|
+
await writeFile(`${log}${PID_SUFFIX}`, '1234 1235 1700000000000 abc\n')
|
|
3386
|
+
assert.equal((await __test.readPidFile(log)).graceMs, undefined)
|
|
3387
|
+
} finally {
|
|
3388
|
+
await rm(dir, { recursive: true, force: true })
|
|
3389
|
+
}
|
|
3390
|
+
})
|