From 17e698d44cf9a23976d1b82817fe37dee766c5fe Mon Sep 17 00:00:00 2001 From: Dan Freeman Date: Wed, 15 Nov 2023 12:40:21 +0000 Subject: [PATCH] WIP --- .github/workflows/ci.yml | 162 +++++++++--------- .../__tests__/cli/custom-extensions.test.ts | 9 +- packages/core/src/common/transform-manager.ts | 2 + test-packages/test-utils/src/project.ts | 5 +- 4 files changed, 92 insertions(+), 86 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0780d26b1..805f5eee9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,89 +20,89 @@ env: CI: true jobs: - test: - name: Test - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v3 - - name: Install Node - uses: actions/setup-node@v3 - with: - node-version: 14 - - name: Locate Yarn Cache - id: yarn-cache-dir-path - run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT - - uses: actions/cache@v3 - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - - name: Install Dependencies - run: yarn install --frozen-lockfile - - name: Lint - run: yarn lint - - name: Build - run: yarn build - - name: Run Tests - uses: coactions/setup-xvfb@v1 - with: - run: yarn test + # test: + # name: Test + # runs-on: ubuntu-latest + # steps: + # - name: Checkout Code + # uses: actions/checkout@v3 + # - name: Install Node + # uses: actions/setup-node@v3 + # with: + # node-version: 14 + # - name: Locate Yarn Cache + # id: yarn-cache-dir-path + # run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + # - uses: actions/cache@v3 + # with: + # path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + # key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + # restore-keys: | + # ${{ runner.os }}-yarn- + # - name: Install Dependencies + # run: yarn install --frozen-lockfile + # - name: Lint + # run: yarn lint + # - name: Build + # run: yarn build + # - name: Run Tests + # uses: coactions/setup-xvfb@v1 + # with: + # run: yarn test - # The Windows runner can be super flaky both with Yarn installs and - # when launching browser tests, so we allow for retries in those steps. - test-windows: - name: Test Windows - runs-on: windows-2022 - steps: - - name: Checkout Code - uses: actions/checkout@v3 - - name: Install Node - uses: actions/setup-node@v3 - with: - node-version: 14 - - name: Install Dependencies - uses: nick-fields/retry@v2 - with: - max_attempts: 2 - timeout_minutes: 10 - command: yarn install --frozen-lockfile - - name: Build - run: yarn build - - name: Test @glint/core - uses: nick-fields/retry@v2 - with: - max_attempts: 2 - timeout_minutes: 20 - command: yarn workspace @glint/core test - - name: Test glint-vscode - uses: nick-fields/retry@v2 - with: - max_attempts: 2 - timeout_minutes: 10 - command: yarn workspace glint-vscode test - - name: Test @glint/scripts - run: yarn workspace @glint/scripts test + # # The Windows runner can be super flaky both with Yarn installs and + # # when launching browser tests, so we allow for retries in those steps. + # test-windows: + # name: Test Windows + # runs-on: windows-2022 + # steps: + # - name: Checkout Code + # uses: actions/checkout@v3 + # - name: Install Node + # uses: actions/setup-node@v3 + # with: + # node-version: 14 + # - name: Install Dependencies + # uses: nick-fields/retry@v2 + # with: + # max_attempts: 2 + # timeout_minutes: 10 + # command: yarn install --frozen-lockfile + # - name: Build + # run: yarn build + # - name: Test @glint/core + # uses: nick-fields/retry@v2 + # with: + # max_attempts: 2 + # timeout_minutes: 20 + # command: yarn workspace @glint/core test + # - name: Test glint-vscode + # uses: nick-fields/retry@v2 + # with: + # max_attempts: 2 + # timeout_minutes: 10 + # command: yarn workspace glint-vscode test + # - name: Test @glint/scripts + # run: yarn workspace @glint/scripts test - test-floating-deps: - name: Test Floating Dependencies - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v3 - - name: Install Node - uses: actions/setup-node@v3 - with: - node-version: 14 - - name: Install Dependencies - run: yarn install --no-lockfile - - name: Build - run: yarn build - - name: Run Tests - uses: coactions/setup-xvfb@v1 - with: - run: yarn test + # test-floating-deps: + # name: Test Floating Dependencies + # runs-on: ubuntu-latest + # steps: + # - name: Checkout Code + # uses: actions/checkout@v3 + # - name: Install Node + # uses: actions/setup-node@v3 + # with: + # node-version: 14 + # - name: Install Dependencies + # run: yarn install --no-lockfile + # - name: Build + # run: yarn build + # - name: Run Tests + # uses: coactions/setup-xvfb@v1 + # with: + # run: yarn test test-ts-nightly: name: Test TypeScript Nightly diff --git a/packages/core/__tests__/cli/custom-extensions.test.ts b/packages/core/__tests__/cli/custom-extensions.test.ts index f165a260b..b855eda1c 100644 --- a/packages/core/__tests__/cli/custom-extensions.test.ts +++ b/packages/core/__tests__/cli/custom-extensions.test.ts @@ -81,7 +81,11 @@ describe('CLI: custom extensions', () => { "Cannot find module './other' or its corresponding type declarations." ); - await watch.writeAndAwaitOutput('other.gjs', 'export const foo = 123;', 'Found 0 errors.'); + try { + await watch.writeAndAwaitOutput('other.gjs', 'export const foo = 123;', 'Found 0 errors.'); + } finally { + console.log(stripAnsi(watch.allOutput)); + } await watch.terminate(); }); @@ -99,7 +103,6 @@ describe('CLI: custom extensions', () => { 'Watching for file changes.' ); - console.log(stripAnsi(watch.allOutput)); expect(output).toMatch('Found 1 error.'); expect(output).toMatch('TS2362'); @@ -114,11 +117,9 @@ describe('CLI: custom extensions', () => { expect(output).toMatch('Found 0 errors.'); - await new Promise((r) => setTimeout(r, 250)); project.remove('other.gjs'); output = await watch.awaitOutput('Watching for file changes.'); - console.log(stripAnsi(watch.allOutput)); expect(output).toMatch('Found 1 error.'); expect(output).toMatch( "Cannot find module './other' or its corresponding type declarations." diff --git a/packages/core/src/common/transform-manager.ts b/packages/core/src/common/transform-manager.ts index fd849f0e3..724732d26 100644 --- a/packages/core/src/common/transform-manager.ts +++ b/packages/core/src/common/transform-manager.ts @@ -212,6 +212,7 @@ export default class TransformManager { let { glintConfig, documents } = this; let callback: ts.FileWatcherCallback = (watchedPath, eventKind) => { + // console.log('watchFileCallback', watchedPath, path); if (eventKind === this.ts.FileWatcherEventKind.Deleted) { // Adding or removing a file invalidates most of what we think we know about module resolution this.moduleResolutionCache.clear(); @@ -254,6 +255,7 @@ export default class TransformManager { } let callback: ts.DirectoryWatcherCallback = (filename) => { + // console.log('watchDirectoryCallback', filename, this.getScriptPathForTS(filename)); // Adding or removing a file invalidates most of what we think we know about module resolution this.moduleResolutionCache.clear(); originalCallback(this.getScriptPathForTS(filename)); diff --git a/test-packages/test-utils/src/project.ts b/test-packages/test-utils/src/project.ts index 15b7d010b..bc2286a59 100644 --- a/test-packages/test-utils/src/project.ts +++ b/test-packages/test-utils/src/project.ts @@ -84,6 +84,7 @@ export class Project { watchOptions: { watchFile: 'fixedPollingInterval', watchDirectory: 'fixedPollingInterval', + synchronousWatchDirectory: true, }, glint: config.glint ?? { environment: 'glimmerx', @@ -267,7 +268,9 @@ class Watch { // If there's still been no output and we have a file to touch, give that a try. if (waited < timeout && touchFile && output === '') { let now = new Date(); - fs.utimesSync(this.project.filePath(touchFile), now, now); + let filePath = this.project.filePath(touchFile); + fs.utimesSync(filePath, now, now); + fs.closeSync(fs.openSync(filePath, 'a')); } };