Skip to content

Commit

Permalink
fix(sync): tmp bug strikes again
Browse files Browse the repository at this point in the history
  • Loading branch information
Yohe-Am committed Dec 21, 2023
1 parent df1cd95 commit 0218117
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 44 deletions.
2 changes: 1 addition & 1 deletion modules/ports/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async function movebleTmpPath(targetDir: string, targetTmpDirName = "tmp") {
if ((await targetPath.stat())?.dev != (await defaultTmpPath.stat())?.dev) {
return targetPath.join(targetTmpDirName);
}
return defaultTmpPath.join("ghjkTmp");
return await defaultTmpPath.join("ghjkTmp").ensureDir();
}

export async function sync(
Expand Down
50 changes: 26 additions & 24 deletions tests/ports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,12 @@ import whiz from "../ports/whiz.ts";
import cpython from "../ports/cpy_bs.ts";
import pipi from "../ports/pipi.ts";

type CustomE2eTestCase = Omit<E2eTestCase, "ePoints"> & { ePoint: string };
type CustomE2eTestCase = Omit<E2eTestCase, "ePoints"> & {
ePoint: string;
ignore?: boolean;
};
// order tests by download size to make failed runs less expensive
const cases: CustomE2eTestCase[] = [
...(Deno.build.os == "linux"
? [
// 8 megs
{
name: "mold",
installConf: mold(),
ePoint: `mold -V`,
},
]
: []),

// 3 megs
{
name: "protoc",
Expand Down Expand Up @@ -63,6 +55,13 @@ const cases: CustomE2eTestCase[] = [
installConf: cargo_binstall(),
ePoint: `cargo-binstall -V`,
},
// 8 megs
{
name: "mold",
installConf: mold(),
ePoint: `mold -V`,
ignore: Deno.build.os != "linux",
},
// 16 megs
{
name: "wasmedge",
Expand Down Expand Up @@ -148,18 +147,21 @@ function testMany(
) {
for (const testCase of cases) {
Deno.test(
`${testGroup} - ${testCase.name}`,
() =>
testFn({
...testCase,
ePoints: ["bash -c", "fish -c", "zsh -c"].map((sh) => ({
cmd: `env ${sh} '${testCase.ePoint}'`,
})),
envs: {
...defaultEnvs,
...testCase.envs,
},
}),
{
name: `${testGroup} - ${testCase.name}`,
ignore: testCase.ignore,
fn: () =>
testFn({
...testCase,
ePoints: ["bash -c", "fish -c", "zsh -c"].map((sh) => ({
cmd: `env ${sh} '${testCase.ePoint}'`,
})),
envs: {
...defaultEnvs,
...testCase.envs,
},
}),
},
);
}
}
Expand Down
39 changes: 20 additions & 19 deletions tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,8 @@ export async function localE2eTest(testCase: E2eTestCase) {
prefix: "ghjk_le2e_",
}),
);

const ghjkDir = await tmpDir.join("ghjk").ensureDir();
await install({
...defaultInstallArgs,
skipExecInstall: false,
ghjkExecInstallDir: ghjkDir.toString(),
// share the system's deno cache
ghjkDenoCacheDir: Deno.env.get("DENO_DIR"),
ghjkDir: ghjkDir.toString(),
// don't modify system shell configs
shellsToHook: [],
});

const installConfArray = Array.isArray(installConf)
? installConf
: [installConf];
Expand Down Expand Up @@ -172,14 +162,17 @@ export const secureConfig = JSON.parse(secConfStr);
ZDOTDIR: ghjkDir.toString(),
GHJK_DIR: ghjkDir.toString(),
};
{
const confHome = await ghjkDir.join(".config").ensureDir();
const fishConfDir = await confHome.join("fish").ensureDir();
await fishConfDir.join("config.fish").createSymlinkTo(
ghjkDir.join("env.fish").toString(),
);
env["XDG_CONFIG_HOME"] = confHome.toString();
}
// install ghjk
await install({
...defaultInstallArgs,
skipExecInstall: false,
ghjkExecInstallDir: ghjkDir.toString(),
// share the system's deno cache
ghjkDenoCacheDir: Deno.env.get("DENO_DIR"),
ghjkDir: ghjkDir.toString(),
// don't modify system shell configs
shellsToHook: [],
});
await $`${ghjkDir.join("ghjk").toString()} print config`
.cwd(tmpDir.toString())
.env(env);
Expand All @@ -194,6 +187,14 @@ export const secureConfig = JSON.parse(secConfStr);
entry.path.toString().slice(ghjkDirLen),
]));
*/
{
const confHome = await ghjkDir.join(".config").ensureDir();
const fishConfDir = await confHome.join("fish").ensureDir();
await fishConfDir.join("config.fish").createSymlinkTo(
ghjkDir.join("env.fish").toString(),
);
env["XDG_CONFIG_HOME"] = confHome.toString();
}
for (const ePoint of ePoints) {
let cmd = $.raw`${ePoint.cmd}`
.cwd(tmpDir.toString())
Expand Down

0 comments on commit 0218117

Please sign in to comment.