Skip to content

Commit

Permalink
test: copy test apps to a temporary directory instead of an ignored p…
Browse files Browse the repository at this point in the history
…roject subdirectory (#1404)
  • Loading branch information
fwouts authored Mar 6, 2023
1 parent a41db1a commit caf4510
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
_tmp_*
dist
frameworks/react/preview/types
frameworks/vue2/preview/modules
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ pro
yarn-debug.log
yarn-error.log
__failures__
_tmp_*
*_screenshot_*.png
!*_screenshot_linux.png
1 change: 0 additions & 1 deletion frameworks/preact/tests/apps/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ packages:
- "frameworks/*"
- "frameworks/*/preview"
- "frameworks/*/tests/apps/*"
- "!frameworks/*/tests/apps/_tmp_*"
- "iframe"
- "integrations/cli"
- "integrations/intellij/daemon"
Expand Down
17 changes: 13 additions & 4 deletions testing/src/test-dir.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { realpathSync } from "fs";
import {
copyFileSync,
lstatSync,
Expand All @@ -10,15 +11,23 @@ import {
symlinkSync,
unlinkSync,
} from "fs-extra";
import os from "os";
import path from "path";

export function duplicateProjectForTesting(testProjectDirPath: string) {
const rootDirPath = path.join(
testProjectDirPath,
"..",
"_tmp_",
const tmpDir = realpathSync(os.tmpdir());
let rootDirPath = path.join(
tmpDir,
`${path.basename(testProjectDirPath)}-${process.pid}`
);
// TODO: Remove this hack because Windows tests fail in CI
// presumably because of different drives.
if (rootDirPath.startsWith("C:\\Users\\RUNNER~")) {
rootDirPath = rootDirPath.replace(
/C:\\Users\\RUNNER~\d+/g,
"D:\\a\\previewjs"
);
}
mkdirpSync(rootDirPath);
sync(testProjectDirPath, rootDirPath);
return rootDirPath;
Expand Down

0 comments on commit caf4510

Please sign in to comment.