History

test(server): run the Antigravity install harness for the host platform (#9574)

Julius Marminge committed 2 months ago

Commit 912276b1 parent 9fa54ee1 file · +32 −25Browse files

Unified · Split

apps/server/src/provider/AntigravityInstallation.test.ts+32−25
@@ -55,9 +55,24 @@ const zipFixtures = { · 54 unmodified lines
5555 "UEsDBBQAAAAIAAAAIl1zEy/oFAAAABQAAAASAAAAYWd5X2FjcF9zZXJ2ZXIuZXhlS8wryUwvSizLLKlUKCoFcnJTuQBQSwMEFAAAAAgAAAAiXV9yAykQAAAADgAAABkAAABsb2NhbGhhcm5lc3NfZXh0ZXJuYWwuZXhly8lPTsxRyEgsykstLuYCAFBLAQIUAxQAAAAIAAAAIl1zEy/oFAAAABQAAAASAAAAAAAAAAAAAADtgQAAAABhZ3lfYWNwX3NlcnZlci5leGVQSwECFAMUAAAACAAAACJdX3IDKRAAAAAOAAAAGQAAAAAAAAAAAAAA7YFEAAAAbG9jYWxoYXJuZXNzX2V4dGVybmFsLmV4ZVBLBQYAAAAAAgACAIcAAACLAAAAAAA=",
5656 };
5757
58−const completeArchive = Buffer.from(zipFixtures.complete, "base64");
58+// The installation checks POSIX exec bits off the real filesystem unless the
59+// platform is win32, so a linux platform mock cannot pass on NTFS. Default to
60+// the host and let the fixture names follow; the suite is about install
61+// mechanics, which are the same on every platform.
62+const hostPlatform: NodeJS.Platform =
63+ HostProcessPlatform.defaultValue() === "win32" ? "win32" : "linux";
64+const completeArchive = Buffer.from(
65+ hostPlatform === "win32" ? zipFixtures.windows : zipFixtures.complete,
66+ "base64",
67+);
68+const executableName = hostPlatform === "win32" ? "agy_acp_server.exe" : "agy_acp_server.par";
69+const harnessName =
70+ hostPlatform === "win32" ? "localharness_external.exe" : "localharness_external";
5971
60−function releaseAsset(archive: Uint8Array = completeArchive, platform: NodeJS.Platform = "linux") {
72+function releaseAsset(
73+ archive: Uint8Array = completeArchive,
74+ platform: NodeJS.Platform = hostPlatform,
75+) {
6176 return {
6277 version: "fixture-new",
6378 url: "https://dl.google.com/antigravity-test.zip",
@@ -128,7 +143,7 @@ const makeHarness = Effect.fn("test.makeAntigravityInstallation")(function* ( · 64 unmodified lines
128143 const path = yield* Path.Path;
129144 const baseDir =
130145 options.baseDir ?? (yield* fs.makeTempDirectoryScoped({ prefix: "t3-agy-test-" }));
131− const platform = options.platform ?? "linux";
146+ const platform = options.platform ?? hostPlatform;
132147 const archive = options.archive ?? completeArchive;
133148 const asset = options.asset === undefined ? releaseAsset(archive, platform) : options.asset;
134149 const managedDirectory = path.join(baseDir, "tools", "antigravity-acp", `${platform}-x64`);
@@ -472,7 +487,7 @@ it.layer(NodeServices.layer)("Antigravity installation", (it) => { · 337 unmodified lines
472487 ...fs,
473488 sink: (target, options) =>
474489 (stage === "download" && target.endsWith("download.zip")) ||
475− (stage === "extract" && target.endsWith("agy_acp_server.par"))
490+ (stage === "extract" && target.endsWith(executableName))
476491 ? fs.sink(target, options).pipe(Sink.mapInputEffect(() => Effect.fail(noSpace)))
477492 : fs.sink(target, options),
478493 writeFileString: (target, content, options) =>
@@ -525,7 +540,7 @@ it.layer(NodeServices.layer)("Antigravity installation", (it) => { · 46 unmodified lines
525540 fileSystem: FileSystem.FileSystem.of({
526541 ...fs,
527542 sink: (target, options) =>
528− phase === "extracting" && target.endsWith("agy_acp_server.par")
543+ phase === "extracting" && target.endsWith(executableName)
529544 ? fs
530545 .sink(target, options)
531546 .pipe(
@@ -691,8 +706,8 @@ it.layer(NodeServices.layer)("Antigravity installation", (it) => { · 159 unmodified lines
691706 const path = yield* Path.Path;
692707 const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-agy-path-test-" });
693708 const externalDirectory = path.join(baseDir, "external");
694− const externalExecutable = path.join(externalDirectory, "agy_acp_server.par");
695− const externalHarness = path.join(externalDirectory, "localharness_external");
709+ const externalExecutable = path.join(externalDirectory, executableName);
710+ const externalHarness = path.join(externalDirectory, harnessName);
696711 yield* fs.makeDirectory(externalDirectory);
697712 yield* fs.writeFileString(externalExecutable, "external server", { mode: 0o755 });
698713 yield* fs.writeFileString(externalHarness, "external harness", { mode: 0o755 });
@@ -711,7 +726,7 @@ it.layer(NodeServices.layer)("Antigravity installation", (it) => { · 12 unmodified lines
711726 source: "override",
712727 managedVersionDirectory: null,
713728 });
714− expect(yield* installation.resolve("agy_acp_server.par")).toMatchObject({
729+ expect(yield* installation.resolve(executableName)).toMatchObject({
715730 source: "override",
716731 });
717732 yield* fs.remove(externalHarness);
@@ -741,7 +756,7 @@ it.layer(NodeServices.layer)("Antigravity installation", (it) => { · 23 unmodified lines
741756 executablePath: externalExecutable,
742757 });
743758 expect(
744− yield* isolated.installation.resolve("agy_acp_server.par", { PATH: externalDirectory }),
759+ yield* isolated.installation.resolve(executableName, { PATH: externalDirectory }),
745760 ).toMatchObject({ source: "override", executablePath: externalExecutable });
746761 }),
747762 );
@@ -774,20 +789,12 @@ it.layer(NodeServices.layer)("Antigravity installation", (it) => { · 26 unmodified lines
774789 yield* fs.remove(previous.harnessPath);
775790 const externalDirectory = path.join(baseDir, "external");
776791 yield* fs.makeDirectory(externalDirectory);
777− yield* fs.writeFileString(
778− path.join(externalDirectory, "agy_acp_server.par"),
779− "external server",
780− {
781− mode: 0o755,
782− },
783− );
784− yield* fs.writeFileString(
785− path.join(externalDirectory, "localharness_external"),
786− "external harness",
787− {
788− mode: 0o755,
789− },
790− );
792+ yield* fs.writeFileString(path.join(externalDirectory, executableName), "external server", {
793+ mode: 0o755,
794+ });
795+ yield* fs.writeFileString(path.join(externalDirectory, harnessName), "external harness", {
796+ mode: 0o755,
797+ });
791798 const restarted = yield* makeHarness({ baseDir, path: externalDirectory });
792799 expect(yield* restarted.installation.state).toMatchObject({
793800 phase: "failed",
@@ -824,8 +831,8 @@ it.layer(NodeServices.layer)("Antigravity installation", (it) => { · 30 unmodified lines
824831 const profileDirectory = path.join(baseDir, "providers", "antigravity", "profile");
825832 yield* fs.makeDirectory(externalDirectory);
826833 yield* fs.makeDirectory(profileDirectory, { recursive: true });
827− const externalExecutable = path.join(externalDirectory, "agy_acp_server.par");
828− const externalHarness = path.join(externalDirectory, "localharness_external");
834+ const externalExecutable = path.join(externalDirectory, executableName);
835+ const externalHarness = path.join(externalDirectory, harnessName);
829836 const profilePath = path.join(profileDirectory, "preferences.json");
830837 yield* fs.writeFileString(externalExecutable, "external server", { mode: 0o755 });
831838 yield* fs.writeFileString(externalHarness, "external harness", { mode: 0o755 });