fix(adb): preserve device paths and prevent destination collisions
Interpret device paths once as POSIX paths and apply only the selected host's filename constraints. Preserve original PM paths and diagnostics, reject duplicate destinations before pulls, and use exact-name filesystem reservations to detect case and Unicode aliases without guessing volume rules. Consolidate failed-package cleanup ownership and strengthen no-output assertions. Validated 44 provider fixture tests, 47 filename/parser tests, six compiled CLI tests, static/docs checks, and package checks. No Android hardware was used.
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
import { expect, it } from "vitest";
|
||||
import { chmod, lstat, readFile } from "node:fs/promises";
|
||||
import { expect, it, onTestFinished } from "vitest";
|
||||
|
||||
import {
|
||||
expectConfigurationRefusal,
|
||||
serveCli as serve,
|
||||
} from "./cliServeHarness.js";
|
||||
import {
|
||||
createTestWorkspace,
|
||||
removeTestWorkspace,
|
||||
} from "../../support/workspace/workspaceFixture.js";
|
||||
|
||||
it.each([
|
||||
[
|
||||
@@ -46,3 +51,40 @@ it("requires the output directory option on pull", async () => {
|
||||
]);
|
||||
expect(result.exitCode).not.toBe(0);
|
||||
});
|
||||
|
||||
it.skipIf(process.platform === "win32")(
|
||||
"refuses a trailing device separator through the CLI before adb or output effects",
|
||||
async () => {
|
||||
const workspace = await createTestWorkspace("rea-adb-cli-pull-");
|
||||
onTestFinished(() => removeTestWorkspace(workspace.root));
|
||||
const adb = await workspace.write(
|
||||
"adb",
|
||||
`#!/bin/sh
|
||||
if [ "$1" = "version" ]; then
|
||||
printf 'Android Debug Bridge version 1.0.41\\nVersion 34.0.5-cli\\nInstalled as %s\\n' "$0"
|
||||
exit 0
|
||||
fi
|
||||
: > '${workspace.path("invoked")}'
|
||||
exit 0
|
||||
`,
|
||||
);
|
||||
await chmod(adb, 0o755);
|
||||
const output = workspace.path("pulls");
|
||||
const result = await serve(
|
||||
[
|
||||
"pull-adb-file",
|
||||
"emulator-5554",
|
||||
"/data/local/tmp/",
|
||||
"--output-directory",
|
||||
output,
|
||||
"--json",
|
||||
],
|
||||
{ REA_ADB_PATH: adb },
|
||||
);
|
||||
expect(JSON.parse(result.stdout)).toMatchObject({
|
||||
code: "invalid_request",
|
||||
});
|
||||
await expect(readFile(workspace.path("invoked"))).rejects.toThrow();
|
||||
await expect(lstat(output)).rejects.toMatchObject({ code: "ENOENT" });
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user