From 27ec1a95e5b336b362c6f20721eac2b2fa1979c9 Mon Sep 17 00:00:00 2001 From: Zixuan Chen Date: Wed, 30 Mar 2022 01:25:12 +0800 Subject: [PATCH] fix: debug & run tests on win --- samples/basic/pnpm-lock.yaml | 511 ++++++++++++++----------- samples/basic/test/fail_to_run.test.ts | 1 + src/TestData.ts | 14 +- src/discover.ts | 21 +- src/extension.ts | 4 +- src/pure/isVitestEnv.ts | 9 +- src/pure/platform.ts | 262 +++++++++++++ src/pure/runner.ts | 22 +- src/pure/utils.ts | 14 +- src/runHandler.ts | 16 +- 10 files changed, 607 insertions(+), 267 deletions(-) create mode 100644 samples/basic/test/fail_to_run.test.ts create mode 100644 src/pure/platform.ts diff --git a/samples/basic/pnpm-lock.yaml b/samples/basic/pnpm-lock.yaml index f845ca9c..6ea341b8 100644 --- a/samples/basic/pnpm-lock.yaml +++ b/samples/basic/pnpm-lock.yaml @@ -2,68 +2,54 @@ lockfileVersion: 5.3 specifiers: vite: ^2.8.6 - vitest: ^0.6.0 + vitest: ^0.8.0 devDependencies: vite: registry.npmmirror.com/vite/2.8.6 - vitest: registry.npmmirror.com/vitest/0.6.0 + vitest: 0.8.0 packages: - registry.npmmirror.com/@types/chai-subset/1.3.3: - resolution: {integrity: sha512-frBecisrNGz+F4T6bcc+NLeolfiojh5FxW2klu669+8BARtyQv2C/GkNW6FUodVe4BroGMP/wER/YDGc7rEllw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@types/chai-subset/-/chai-subset-1.3.3.tgz} - name: '@types/chai-subset' - version: 1.3.3 + /@types/chai-subset/1.3.3: + resolution: {integrity: sha512-frBecisrNGz+F4T6bcc+NLeolfiojh5FxW2klu669+8BARtyQv2C/GkNW6FUodVe4BroGMP/wER/YDGc7rEllw==} dependencies: - '@types/chai': registry.npmmirror.com/@types/chai/4.3.0 + '@types/chai': 4.3.0 dev: true - registry.npmmirror.com/@types/chai/4.3.0: - resolution: {integrity: sha512-/ceqdqeRraGolFTcfoXNiqjyQhZzbINDngeoAq9GoHa8PPK1yNzTaxWjA6BFWp5Ua9JpXEMSS4s5i9tS0hOJtw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/@types/chai/-/chai-4.3.0.tgz} - name: '@types/chai' - version: 4.3.0 + /@types/chai/4.3.0: + resolution: {integrity: sha512-/ceqdqeRraGolFTcfoXNiqjyQhZzbINDngeoAq9GoHa8PPK1yNzTaxWjA6BFWp5Ua9JpXEMSS4s5i9tS0hOJtw==} dev: true - registry.npmmirror.com/assertion-error/1.1.0: - resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/assertion-error/-/assertion-error-1.1.0.tgz} - name: assertion-error - version: 1.1.0 + /assertion-error/1.1.0: + resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==} dev: true - registry.npmmirror.com/chai/4.3.6: - resolution: {integrity: sha512-bbcp3YfHCUzMOvKqsztczerVgBKSsEijCySNlHHbX3VG1nskvqjz5Rfso1gGwD6w6oOV3eI60pKuMOV5MV7p3Q==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/chai/-/chai-4.3.6.tgz} - name: chai - version: 4.3.6 + /chai/4.3.6: + resolution: {integrity: sha512-bbcp3YfHCUzMOvKqsztczerVgBKSsEijCySNlHHbX3VG1nskvqjz5Rfso1gGwD6w6oOV3eI60pKuMOV5MV7p3Q==} engines: {node: '>=4'} dependencies: - assertion-error: registry.npmmirror.com/assertion-error/1.1.0 - check-error: registry.npmmirror.com/check-error/1.0.2 - deep-eql: registry.npmmirror.com/deep-eql/3.0.1 - get-func-name: registry.npmmirror.com/get-func-name/2.0.0 - loupe: registry.npmmirror.com/loupe/2.3.4 - pathval: registry.npmmirror.com/pathval/1.1.1 - type-detect: registry.npmmirror.com/type-detect/4.0.8 - dev: true - - registry.npmmirror.com/check-error/1.0.2: - resolution: {integrity: sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/check-error/-/check-error-1.0.2.tgz} - name: check-error - version: 1.0.2 + assertion-error: 1.1.0 + check-error: 1.0.2 + deep-eql: 3.0.1 + get-func-name: 2.0.0 + loupe: 2.3.4 + pathval: 1.1.1 + type-detect: 4.0.8 + dev: true + + /check-error/1.0.2: + resolution: {integrity: sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=} dev: true - registry.npmmirror.com/deep-eql/3.0.1: - resolution: {integrity: sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/deep-eql/-/deep-eql-3.0.1.tgz} - name: deep-eql - version: 3.0.1 + /deep-eql/3.0.1: + resolution: {integrity: sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==} engines: {node: '>=0.12'} dependencies: - type-detect: registry.npmmirror.com/type-detect/4.0.8 + type-detect: 4.0.8 dev: true - registry.npmmirror.com/esbuild-android-64/0.14.25: - resolution: {integrity: sha512-L5vCUk7TzFbBnoESNoXjU3x9+/+7TDIE/1mTfy/erAfvZAqC+S3sp/Qa9wkypFMcFvN9FzvESkTlpeQDolREtQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/esbuild-android-64/-/esbuild-android-64-0.14.25.tgz} - name: esbuild-android-64 - version: 0.14.25 + /esbuild-android-64/0.14.25: + resolution: {integrity: sha512-L5vCUk7TzFbBnoESNoXjU3x9+/+7TDIE/1mTfy/erAfvZAqC+S3sp/Qa9wkypFMcFvN9FzvESkTlpeQDolREtQ==} engines: {node: '>=12'} cpu: [x64] os: [android] @@ -71,10 +57,8 @@ packages: dev: true optional: true - registry.npmmirror.com/esbuild-android-arm64/0.14.25: - resolution: {integrity: sha512-4jv5xPjM/qNm27T5j3ZEck0PvjgQtoMHnz4FzwF5zNP56PvY2CT0WStcAIl6jNlsuDdN63rk2HRBIsO6xFbcFw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/esbuild-android-arm64/-/esbuild-android-arm64-0.14.25.tgz} - name: esbuild-android-arm64 - version: 0.14.25 + /esbuild-android-arm64/0.14.25: + resolution: {integrity: sha512-4jv5xPjM/qNm27T5j3ZEck0PvjgQtoMHnz4FzwF5zNP56PvY2CT0WStcAIl6jNlsuDdN63rk2HRBIsO6xFbcFw==} engines: {node: '>=12'} cpu: [arm64] os: [android] @@ -82,10 +66,8 @@ packages: dev: true optional: true - registry.npmmirror.com/esbuild-darwin-64/0.14.25: - resolution: {integrity: sha512-TGp8tuudIxOyWd1+8aYPxQmC1ZQyvij/AfNBa35RubixD0zJ1vkKHVAzo0Zao1zcG6pNqiSyzfPto8vmg0s7oA==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/esbuild-darwin-64/-/esbuild-darwin-64-0.14.25.tgz} - name: esbuild-darwin-64 - version: 0.14.25 + /esbuild-darwin-64/0.14.25: + resolution: {integrity: sha512-TGp8tuudIxOyWd1+8aYPxQmC1ZQyvij/AfNBa35RubixD0zJ1vkKHVAzo0Zao1zcG6pNqiSyzfPto8vmg0s7oA==} engines: {node: '>=12'} cpu: [x64] os: [darwin] @@ -93,10 +75,8 @@ packages: dev: true optional: true - registry.npmmirror.com/esbuild-darwin-arm64/0.14.25: - resolution: {integrity: sha512-oTcDgdm0MDVEmw2DWu8BV68pYuImpFgvWREPErBZmNA4MYKGuBRaCiJqq6jZmBR1x+3y1DWCjez+5uLtuAm6mw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.14.25.tgz} - name: esbuild-darwin-arm64 - version: 0.14.25 + /esbuild-darwin-arm64/0.14.25: + resolution: {integrity: sha512-oTcDgdm0MDVEmw2DWu8BV68pYuImpFgvWREPErBZmNA4MYKGuBRaCiJqq6jZmBR1x+3y1DWCjez+5uLtuAm6mw==} engines: {node: '>=12'} cpu: [arm64] os: [darwin] @@ -104,10 +84,8 @@ packages: dev: true optional: true - registry.npmmirror.com/esbuild-freebsd-64/0.14.25: - resolution: {integrity: sha512-ueAqbnMZ8arnuLH8tHwTCQYeptnHOUV7vA6px6j4zjjQwDx7TdP7kACPf3TLZLdJQ3CAD1XCvQ2sPhX+8tacvQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/esbuild-freebsd-64/-/esbuild-freebsd-64-0.14.25.tgz} - name: esbuild-freebsd-64 - version: 0.14.25 + /esbuild-freebsd-64/0.14.25: + resolution: {integrity: sha512-ueAqbnMZ8arnuLH8tHwTCQYeptnHOUV7vA6px6j4zjjQwDx7TdP7kACPf3TLZLdJQ3CAD1XCvQ2sPhX+8tacvQ==} engines: {node: '>=12'} cpu: [x64] os: [freebsd] @@ -115,10 +93,8 @@ packages: dev: true optional: true - registry.npmmirror.com/esbuild-freebsd-arm64/0.14.25: - resolution: {integrity: sha512-+ZVWud2HKh+Ob6k/qiJWjBtUg4KmJGGmbvEXXW1SNKS7hW7HU+Zq2ZCcE1akFxOPkVB+EhOty/sSek30tkCYug==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.14.25.tgz} - name: esbuild-freebsd-arm64 - version: 0.14.25 + /esbuild-freebsd-arm64/0.14.25: + resolution: {integrity: sha512-+ZVWud2HKh+Ob6k/qiJWjBtUg4KmJGGmbvEXXW1SNKS7hW7HU+Zq2ZCcE1akFxOPkVB+EhOty/sSek30tkCYug==} engines: {node: '>=12'} cpu: [arm64] os: [freebsd] @@ -126,10 +102,8 @@ packages: dev: true optional: true - registry.npmmirror.com/esbuild-linux-32/0.14.25: - resolution: {integrity: sha512-3OP/lwV3kCzEz45tobH9nj+uE4ubhGsfx+tn0L26WAGtUbmmcRpqy7XRG/qK7h1mClZ+eguIANcQntYMdYklfw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/esbuild-linux-32/-/esbuild-linux-32-0.14.25.tgz} - name: esbuild-linux-32 - version: 0.14.25 + /esbuild-linux-32/0.14.25: + resolution: {integrity: sha512-3OP/lwV3kCzEz45tobH9nj+uE4ubhGsfx+tn0L26WAGtUbmmcRpqy7XRG/qK7h1mClZ+eguIANcQntYMdYklfw==} engines: {node: '>=12'} cpu: [ia32] os: [linux] @@ -137,10 +111,8 @@ packages: dev: true optional: true - registry.npmmirror.com/esbuild-linux-64/0.14.25: - resolution: {integrity: sha512-+aKHdHZmX9qwVlQmu5xYXh7GsBFf4TWrePgeJTalhXHOG7NNuUwoHmketGiZEoNsWyyqwH9rE5BC+iwcLY30Ug==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/esbuild-linux-64/-/esbuild-linux-64-0.14.25.tgz} - name: esbuild-linux-64 - version: 0.14.25 + /esbuild-linux-64/0.14.25: + resolution: {integrity: sha512-+aKHdHZmX9qwVlQmu5xYXh7GsBFf4TWrePgeJTalhXHOG7NNuUwoHmketGiZEoNsWyyqwH9rE5BC+iwcLY30Ug==} engines: {node: '>=12'} cpu: [x64] os: [linux] @@ -148,10 +120,8 @@ packages: dev: true optional: true - registry.npmmirror.com/esbuild-linux-arm/0.14.25: - resolution: {integrity: sha512-aTLcE2VBoLydL943REcAcgnDi3bHtmULSXWLbjtBdtykRatJVSxKMjK9YlBXUZC4/YcNQfH7AxwVeQr9fNxPhw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/esbuild-linux-arm/-/esbuild-linux-arm-0.14.25.tgz} - name: esbuild-linux-arm - version: 0.14.25 + /esbuild-linux-arm/0.14.25: + resolution: {integrity: sha512-aTLcE2VBoLydL943REcAcgnDi3bHtmULSXWLbjtBdtykRatJVSxKMjK9YlBXUZC4/YcNQfH7AxwVeQr9fNxPhw==} engines: {node: '>=12'} cpu: [arm] os: [linux] @@ -159,10 +129,8 @@ packages: dev: true optional: true - registry.npmmirror.com/esbuild-linux-arm64/0.14.25: - resolution: {integrity: sha512-UxfenPx/wSZx55gScCImPtXekvZQLI2GW3qe5dtlmU7luiqhp5GWPzGeQEbD3yN3xg/pHc671m5bma5Ns7lBHw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/esbuild-linux-arm64/-/esbuild-linux-arm64-0.14.25.tgz} - name: esbuild-linux-arm64 - version: 0.14.25 + /esbuild-linux-arm64/0.14.25: + resolution: {integrity: sha512-UxfenPx/wSZx55gScCImPtXekvZQLI2GW3qe5dtlmU7luiqhp5GWPzGeQEbD3yN3xg/pHc671m5bma5Ns7lBHw==} engines: {node: '>=12'} cpu: [arm64] os: [linux] @@ -170,10 +138,8 @@ packages: dev: true optional: true - registry.npmmirror.com/esbuild-linux-mips64le/0.14.25: - resolution: {integrity: sha512-wLWYyqVfYx9Ur6eU5RT92yJVsaBGi5RdkoWqRHOqcJ38Kn60QMlcghsKeWfe9jcYut8LangYZ98xO1LxIoSXrQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.14.25.tgz} - name: esbuild-linux-mips64le - version: 0.14.25 + /esbuild-linux-mips64le/0.14.25: + resolution: {integrity: sha512-wLWYyqVfYx9Ur6eU5RT92yJVsaBGi5RdkoWqRHOqcJ38Kn60QMlcghsKeWfe9jcYut8LangYZ98xO1LxIoSXrQ==} engines: {node: '>=12'} cpu: [mips64el] os: [linux] @@ -181,10 +147,8 @@ packages: dev: true optional: true - registry.npmmirror.com/esbuild-linux-ppc64le/0.14.25: - resolution: {integrity: sha512-0dR6Csl6Zas3g4p9ULckEl8Mo8IInJh33VCJ3eaV1hj9+MHGdmDOakYMN8MZP9/5nl+NU/0ygpd14cWgy8uqRw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.14.25.tgz} - name: esbuild-linux-ppc64le - version: 0.14.25 + /esbuild-linux-ppc64le/0.14.25: + resolution: {integrity: sha512-0dR6Csl6Zas3g4p9ULckEl8Mo8IInJh33VCJ3eaV1hj9+MHGdmDOakYMN8MZP9/5nl+NU/0ygpd14cWgy8uqRw==} engines: {node: '>=12'} cpu: [ppc64] os: [linux] @@ -192,10 +156,8 @@ packages: dev: true optional: true - registry.npmmirror.com/esbuild-linux-riscv64/0.14.25: - resolution: {integrity: sha512-J4d20HDmTrgvhR0bdkDhvvJGaikH3LzXQnNaseo8rcw9Yqby9A90gKUmWpfwqLVNRILvNnAmKLfBjCKU9ajg8w==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.14.25.tgz} - name: esbuild-linux-riscv64 - version: 0.14.25 + /esbuild-linux-riscv64/0.14.25: + resolution: {integrity: sha512-J4d20HDmTrgvhR0bdkDhvvJGaikH3LzXQnNaseo8rcw9Yqby9A90gKUmWpfwqLVNRILvNnAmKLfBjCKU9ajg8w==} engines: {node: '>=12'} cpu: [riscv64] os: [linux] @@ -203,10 +165,8 @@ packages: dev: true optional: true - registry.npmmirror.com/esbuild-linux-s390x/0.14.25: - resolution: {integrity: sha512-YI2d5V6nTE73ZnhEKQD7MtsPs1EtUZJ3obS21oxQxGbbRw1G+PtJKjNyur+3t6nzHP9oTg6GHQ3S3hOLLmbDIQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/esbuild-linux-s390x/-/esbuild-linux-s390x-0.14.25.tgz} - name: esbuild-linux-s390x - version: 0.14.25 + /esbuild-linux-s390x/0.14.25: + resolution: {integrity: sha512-YI2d5V6nTE73ZnhEKQD7MtsPs1EtUZJ3obS21oxQxGbbRw1G+PtJKjNyur+3t6nzHP9oTg6GHQ3S3hOLLmbDIQ==} engines: {node: '>=12'} cpu: [s390x] os: [linux] @@ -214,10 +174,8 @@ packages: dev: true optional: true - registry.npmmirror.com/esbuild-netbsd-64/0.14.25: - resolution: {integrity: sha512-TKIVgNWLUOkr+Exrye70XTEE1lJjdQXdM4tAXRzfHE9iBA7LXWcNtVIuSnphTqpanPzTDFarF0yqq4kpbC6miA==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/esbuild-netbsd-64/-/esbuild-netbsd-64-0.14.25.tgz} - name: esbuild-netbsd-64 - version: 0.14.25 + /esbuild-netbsd-64/0.14.25: + resolution: {integrity: sha512-TKIVgNWLUOkr+Exrye70XTEE1lJjdQXdM4tAXRzfHE9iBA7LXWcNtVIuSnphTqpanPzTDFarF0yqq4kpbC6miA==} engines: {node: '>=12'} cpu: [x64] os: [netbsd] @@ -225,10 +183,8 @@ packages: dev: true optional: true - registry.npmmirror.com/esbuild-openbsd-64/0.14.25: - resolution: {integrity: sha512-QgFJ37A15D7NIXBTYEqz29+uw3nNBOIyog+3kFidANn6kjw0GHZ0lEYQn+cwjyzu94WobR+fes7cTl/ZYlHb1A==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/esbuild-openbsd-64/-/esbuild-openbsd-64-0.14.25.tgz} - name: esbuild-openbsd-64 - version: 0.14.25 + /esbuild-openbsd-64/0.14.25: + resolution: {integrity: sha512-QgFJ37A15D7NIXBTYEqz29+uw3nNBOIyog+3kFidANn6kjw0GHZ0lEYQn+cwjyzu94WobR+fes7cTl/ZYlHb1A==} engines: {node: '>=12'} cpu: [x64] os: [openbsd] @@ -236,10 +192,8 @@ packages: dev: true optional: true - registry.npmmirror.com/esbuild-sunos-64/0.14.25: - resolution: {integrity: sha512-rmWfjUItYIVlqr5EnTH1+GCxXiBOC42WBZ3w++qh7n2cS9Xo0lO5pGSG2N+huOU2fX5L+6YUuJ78/vOYvefeFw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/esbuild-sunos-64/-/esbuild-sunos-64-0.14.25.tgz} - name: esbuild-sunos-64 - version: 0.14.25 + /esbuild-sunos-64/0.14.25: + resolution: {integrity: sha512-rmWfjUItYIVlqr5EnTH1+GCxXiBOC42WBZ3w++qh7n2cS9Xo0lO5pGSG2N+huOU2fX5L+6YUuJ78/vOYvefeFw==} engines: {node: '>=12'} cpu: [x64] os: [sunos] @@ -247,10 +201,8 @@ packages: dev: true optional: true - registry.npmmirror.com/esbuild-windows-32/0.14.25: - resolution: {integrity: sha512-HGAxVUofl3iUIz9W10Y9XKtD0bNsK9fBXv1D55N/ljNvkrAYcGB8YCm0v7DjlwtyS6ws3dkdQyXadbxkbzaKOA==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/esbuild-windows-32/-/esbuild-windows-32-0.14.25.tgz} - name: esbuild-windows-32 - version: 0.14.25 + /esbuild-windows-32/0.14.25: + resolution: {integrity: sha512-HGAxVUofl3iUIz9W10Y9XKtD0bNsK9fBXv1D55N/ljNvkrAYcGB8YCm0v7DjlwtyS6ws3dkdQyXadbxkbzaKOA==} engines: {node: '>=12'} cpu: [ia32] os: [win32] @@ -258,10 +210,8 @@ packages: dev: true optional: true - registry.npmmirror.com/esbuild-windows-64/0.14.25: - resolution: {integrity: sha512-TirEohRkfWU9hXLgoDxzhMQD1g8I2mOqvdQF2RS9E/wbkORTAqJHyh7wqGRCQAwNzdNXdg3JAyhQ9/177AadWA==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/esbuild-windows-64/-/esbuild-windows-64-0.14.25.tgz} - name: esbuild-windows-64 - version: 0.14.25 + /esbuild-windows-64/0.14.25: + resolution: {integrity: sha512-TirEohRkfWU9hXLgoDxzhMQD1g8I2mOqvdQF2RS9E/wbkORTAqJHyh7wqGRCQAwNzdNXdg3JAyhQ9/177AadWA==} engines: {node: '>=12'} cpu: [x64] os: [win32] @@ -269,10 +219,8 @@ packages: dev: true optional: true - registry.npmmirror.com/esbuild-windows-arm64/0.14.25: - resolution: {integrity: sha512-4ype9ERiI45rSh+R8qUoBtaj6kJvUOI7oVLhKqPEpcF4Pa5PpT3hm/mXAyotJHREkHpM87PAJcA442mLnbtlNA==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/esbuild-windows-arm64/-/esbuild-windows-arm64-0.14.25.tgz} - name: esbuild-windows-arm64 - version: 0.14.25 + /esbuild-windows-arm64/0.14.25: + resolution: {integrity: sha512-4ype9ERiI45rSh+R8qUoBtaj6kJvUOI7oVLhKqPEpcF4Pa5PpT3hm/mXAyotJHREkHpM87PAJcA442mLnbtlNA==} engines: {node: '>=12'} cpu: [arm64] os: [win32] @@ -280,58 +228,235 @@ packages: dev: true optional: true - registry.npmmirror.com/esbuild/0.14.25: - resolution: {integrity: sha512-4JHEIOMNFvK09ziiL+iVmldIhLbn49V4NAVo888tcGFKedEZY/Y8YapfStJ6zSE23tzYPKxqKwQBnQoIO0BI/Q==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/esbuild/-/esbuild-0.14.25.tgz} - name: esbuild - version: 0.14.25 + /esbuild/0.14.25: + resolution: {integrity: sha512-4JHEIOMNFvK09ziiL+iVmldIhLbn49V4NAVo888tcGFKedEZY/Y8YapfStJ6zSE23tzYPKxqKwQBnQoIO0BI/Q==} engines: {node: '>=12'} hasBin: true requiresBuild: true optionalDependencies: - esbuild-android-64: registry.npmmirror.com/esbuild-android-64/0.14.25 - esbuild-android-arm64: registry.npmmirror.com/esbuild-android-arm64/0.14.25 - esbuild-darwin-64: registry.npmmirror.com/esbuild-darwin-64/0.14.25 - esbuild-darwin-arm64: registry.npmmirror.com/esbuild-darwin-arm64/0.14.25 - esbuild-freebsd-64: registry.npmmirror.com/esbuild-freebsd-64/0.14.25 - esbuild-freebsd-arm64: registry.npmmirror.com/esbuild-freebsd-arm64/0.14.25 - esbuild-linux-32: registry.npmmirror.com/esbuild-linux-32/0.14.25 - esbuild-linux-64: registry.npmmirror.com/esbuild-linux-64/0.14.25 - esbuild-linux-arm: registry.npmmirror.com/esbuild-linux-arm/0.14.25 - esbuild-linux-arm64: registry.npmmirror.com/esbuild-linux-arm64/0.14.25 - esbuild-linux-mips64le: registry.npmmirror.com/esbuild-linux-mips64le/0.14.25 - esbuild-linux-ppc64le: registry.npmmirror.com/esbuild-linux-ppc64le/0.14.25 - esbuild-linux-riscv64: registry.npmmirror.com/esbuild-linux-riscv64/0.14.25 - esbuild-linux-s390x: registry.npmmirror.com/esbuild-linux-s390x/0.14.25 - esbuild-netbsd-64: registry.npmmirror.com/esbuild-netbsd-64/0.14.25 - esbuild-openbsd-64: registry.npmmirror.com/esbuild-openbsd-64/0.14.25 - esbuild-sunos-64: registry.npmmirror.com/esbuild-sunos-64/0.14.25 - esbuild-windows-32: registry.npmmirror.com/esbuild-windows-32/0.14.25 - esbuild-windows-64: registry.npmmirror.com/esbuild-windows-64/0.14.25 - esbuild-windows-arm64: registry.npmmirror.com/esbuild-windows-arm64/0.14.25 - dev: true - - registry.npmmirror.com/fsevents/2.3.2: - resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/fsevents/-/fsevents-2.3.2.tgz} - name: fsevents - version: 2.3.2 + esbuild-android-64: 0.14.25 + esbuild-android-arm64: 0.14.25 + esbuild-darwin-64: 0.14.25 + esbuild-darwin-arm64: 0.14.25 + esbuild-freebsd-64: 0.14.25 + esbuild-freebsd-arm64: 0.14.25 + esbuild-linux-32: 0.14.25 + esbuild-linux-64: 0.14.25 + esbuild-linux-arm: 0.14.25 + esbuild-linux-arm64: 0.14.25 + esbuild-linux-mips64le: 0.14.25 + esbuild-linux-ppc64le: 0.14.25 + esbuild-linux-riscv64: 0.14.25 + esbuild-linux-s390x: 0.14.25 + esbuild-netbsd-64: 0.14.25 + esbuild-openbsd-64: 0.14.25 + esbuild-sunos-64: 0.14.25 + esbuild-windows-32: 0.14.25 + esbuild-windows-64: 0.14.25 + esbuild-windows-arm64: 0.14.25 + dev: true + + /fsevents/2.3.2: + resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} os: [darwin] requiresBuild: true dev: true optional: true + /function-bind/1.1.1: + resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==} + dev: true + + /get-func-name/2.0.0: + resolution: {integrity: sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=} + dev: true + + /has/1.0.3: + resolution: {integrity: sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==} + engines: {node: '>= 0.4.0'} + dependencies: + function-bind: 1.1.1 + dev: true + + /is-core-module/2.8.1: + resolution: {integrity: sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==} + dependencies: + has: 1.0.3 + dev: true + + /local-pkg/0.4.1: + resolution: {integrity: sha512-lL87ytIGP2FU5PWwNDo0w3WhIo2gopIAxPg9RxDYF7m4rr5ahuZxP22xnJHIvaLTe4Z9P6uKKY2UHiwyB4pcrw==} + engines: {node: '>=14'} + dev: true + + /loupe/2.3.4: + resolution: {integrity: sha512-OvKfgCC2Ndby6aSTREl5aCCPTNIzlDfQZvZxNUrBrihDhL3xcrYegTblhmEiCrg2kKQz4XsFIaemE5BF4ybSaQ==} + dependencies: + get-func-name: 2.0.0 + dev: true + + /nanoid/3.3.1: + resolution: {integrity: sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw==} + engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} + hasBin: true + dev: true + + /path-parse/1.0.7: + resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} + dev: true + + /pathval/1.1.1: + resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==} + dev: true + + /picocolors/1.0.0: + resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==} + dev: true + + /postcss/8.4.8: + resolution: {integrity: sha512-2tXEqGxrjvAO6U+CJzDL2Fk2kPHTv1jQsYkSoMeOis2SsYaXRO2COxTdQp99cYvif9JTXaAk9lYGc3VhJt7JPQ==} + engines: {node: ^10 || ^12 || >=14} + dependencies: + nanoid: 3.3.1 + picocolors: 1.0.0 + source-map-js: 1.0.2 + dev: true + + /resolve/1.22.0: + resolution: {integrity: sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==} + hasBin: true + dependencies: + is-core-module: 2.8.1 + path-parse: 1.0.7 + supports-preserve-symlinks-flag: 1.0.0 + dev: true + + /rollup/2.70.0: + resolution: {integrity: sha512-iEzYw+syFxQ0X9RefVwhr8BA2TNJsTaX8L8dhyeyMECDbmiba+8UQzcu+xZdji0+JQ+s7kouQnw+9Oz5M19XKA==} + engines: {node: '>=10.0.0'} + hasBin: true + optionalDependencies: + fsevents: 2.3.2 + dev: true + + /source-map-js/1.0.2: + resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==} + engines: {node: '>=0.10.0'} + dev: true + + /supports-preserve-symlinks-flag/1.0.0: + resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} + engines: {node: '>= 0.4'} + dev: true + + /tinypool/0.1.2: + resolution: {integrity: sha512-fvtYGXoui2RpeMILfkvGIgOVkzJEGediv8UJt7TxdAOY8pnvUkFg/fkvqTfXG9Acc9S17Cnn1S4osDc2164guA==} + engines: {node: '>=14.0.0'} + dev: true + + /tinyspy/0.3.0: + resolution: {integrity: sha512-c5uFHqtUp74R2DJE3/Efg0mH5xicmgziaQXMm/LvuuZn3RdpADH32aEGDRyCzObXT1DNfwDMqRQ/Drh1MlO12g==} + engines: {node: '>=14.0.0'} + dev: true + + /type-detect/4.0.8: + resolution: {integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==} + engines: {node: '>=4'} + dev: true + + /vite/2.8.6: + resolution: {integrity: sha512-e4H0QpludOVKkmOsRyqQ7LTcMUDF3mcgyNU4lmi0B5JUbe0ZxeBBl8VoZ8Y6Rfn9eFKYtdXNPcYK97ZwH+K2ug==} + engines: {node: '>=12.2.0'} + hasBin: true + peerDependencies: + less: '*' + sass: '*' + stylus: '*' + peerDependenciesMeta: + less: + optional: true + sass: + optional: true + stylus: + optional: true + dependencies: + esbuild: 0.14.25 + postcss: 8.4.8 + resolve: 1.22.0 + rollup: 2.70.0 + optionalDependencies: + fsevents: 2.3.2 + dev: true + + /vitest/0.8.0: + resolution: {integrity: sha512-8m8OufAQWXlNpjm5dTe5Lc60zruguKJljunveueYrd4aoeXaQvggLX0SPmIW3G6PDtnBdNEynSi+6pibjnutQA==} + engines: {node: '>=v14.19.1'} + hasBin: true + peerDependencies: + '@vitest/ui': '*' + c8: '*' + happy-dom: '*' + jsdom: '*' + peerDependenciesMeta: + '@vitest/ui': + optional: true + c8: + optional: true + happy-dom: + optional: true + jsdom: + optional: true + dependencies: + '@types/chai': 4.3.0 + '@types/chai-subset': 1.3.3 + chai: 4.3.6 + local-pkg: 0.4.1 + tinypool: 0.1.2 + tinyspy: 0.3.0 + vite: 2.8.6 + transitivePeerDependencies: + - less + - sass + - stylus + dev: true + + registry.npmmirror.com/esbuild/0.14.25: + resolution: {integrity: sha512-4JHEIOMNFvK09ziiL+iVmldIhLbn49V4NAVo888tcGFKedEZY/Y8YapfStJ6zSE23tzYPKxqKwQBnQoIO0BI/Q==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/esbuild/-/esbuild-0.14.25.tgz} + name: esbuild + version: 0.14.25 + engines: {node: '>=12'} + hasBin: true + requiresBuild: true + optionalDependencies: + esbuild-android-64: 0.14.25 + esbuild-android-arm64: 0.14.25 + esbuild-darwin-64: 0.14.25 + esbuild-darwin-arm64: 0.14.25 + esbuild-freebsd-64: 0.14.25 + esbuild-freebsd-arm64: 0.14.25 + esbuild-linux-32: 0.14.25 + esbuild-linux-64: 0.14.25 + esbuild-linux-arm: 0.14.25 + esbuild-linux-arm64: 0.14.25 + esbuild-linux-mips64le: 0.14.25 + esbuild-linux-ppc64le: 0.14.25 + esbuild-linux-riscv64: 0.14.25 + esbuild-linux-s390x: 0.14.25 + esbuild-netbsd-64: 0.14.25 + esbuild-openbsd-64: 0.14.25 + esbuild-sunos-64: 0.14.25 + esbuild-windows-32: 0.14.25 + esbuild-windows-64: 0.14.25 + esbuild-windows-arm64: 0.14.25 + dev: true + registry.npmmirror.com/function-bind/1.1.1: resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/function-bind/-/function-bind-1.1.1.tgz} name: function-bind version: 1.1.1 dev: true - registry.npmmirror.com/get-func-name/2.0.0: - resolution: {integrity: sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/get-func-name/-/get-func-name-2.0.0.tgz} - name: get-func-name - version: 2.0.0 - dev: true - registry.npmmirror.com/has/1.0.3: resolution: {integrity: sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/has/-/has-1.0.3.tgz} name: has @@ -349,21 +474,6 @@ packages: has: registry.npmmirror.com/has/1.0.3 dev: true - registry.npmmirror.com/local-pkg/0.4.1: - resolution: {integrity: sha512-lL87ytIGP2FU5PWwNDo0w3WhIo2gopIAxPg9RxDYF7m4rr5ahuZxP22xnJHIvaLTe4Z9P6uKKY2UHiwyB4pcrw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/local-pkg/-/local-pkg-0.4.1.tgz} - name: local-pkg - version: 0.4.1 - engines: {node: '>=14'} - dev: true - - registry.npmmirror.com/loupe/2.3.4: - resolution: {integrity: sha512-OvKfgCC2Ndby6aSTREl5aCCPTNIzlDfQZvZxNUrBrihDhL3xcrYegTblhmEiCrg2kKQz4XsFIaemE5BF4ybSaQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/loupe/-/loupe-2.3.4.tgz} - name: loupe - version: 2.3.4 - dependencies: - get-func-name: registry.npmmirror.com/get-func-name/2.0.0 - dev: true - registry.npmmirror.com/nanoid/3.3.1: resolution: {integrity: sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/nanoid/-/nanoid-3.3.1.tgz} name: nanoid @@ -378,12 +488,6 @@ packages: version: 1.0.7 dev: true - registry.npmmirror.com/pathval/1.1.1: - resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/pathval/-/pathval-1.1.1.tgz} - name: pathval - version: 1.1.1 - dev: true - registry.npmmirror.com/picocolors/1.0.0: resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/picocolors/-/picocolors-1.0.0.tgz} name: picocolors @@ -419,7 +523,7 @@ packages: engines: {node: '>=10.0.0'} hasBin: true optionalDependencies: - fsevents: registry.npmmirror.com/fsevents/2.3.2 + fsevents: 2.3.2 dev: true registry.npmmirror.com/source-map-js/1.0.2: @@ -436,27 +540,6 @@ packages: engines: {node: '>= 0.4'} dev: true - registry.npmmirror.com/tinypool/0.1.2: - resolution: {integrity: sha512-fvtYGXoui2RpeMILfkvGIgOVkzJEGediv8UJt7TxdAOY8pnvUkFg/fkvqTfXG9Acc9S17Cnn1S4osDc2164guA==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/tinypool/-/tinypool-0.1.2.tgz} - name: tinypool - version: 0.1.2 - engines: {node: '>=14.0.0'} - dev: true - - registry.npmmirror.com/tinyspy/0.3.0: - resolution: {integrity: sha512-c5uFHqtUp74R2DJE3/Efg0mH5xicmgziaQXMm/LvuuZn3RdpADH32aEGDRyCzObXT1DNfwDMqRQ/Drh1MlO12g==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/tinyspy/-/tinyspy-0.3.0.tgz} - name: tinyspy - version: 0.3.0 - engines: {node: '>=14.0.0'} - dev: true - - registry.npmmirror.com/type-detect/4.0.8: - resolution: {integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/type-detect/-/type-detect-4.0.8.tgz} - name: type-detect - version: 4.0.8 - engines: {node: '>=4'} - dev: true - registry.npmmirror.com/vite/2.8.6: resolution: {integrity: sha512-e4H0QpludOVKkmOsRyqQ7LTcMUDF3mcgyNU4lmi0B5JUbe0ZxeBBl8VoZ8Y6Rfn9eFKYtdXNPcYK97ZwH+K2ug==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/vite/-/vite-2.8.6.tgz} name: vite @@ -480,39 +563,5 @@ packages: resolve: registry.npmmirror.com/resolve/1.22.0 rollup: registry.npmmirror.com/rollup/2.70.0 optionalDependencies: - fsevents: registry.npmmirror.com/fsevents/2.3.2 - dev: true - - registry.npmmirror.com/vitest/0.6.0: - resolution: {integrity: sha512-FuIkLHCQxz6rO35MQROUtVdwcBaYnt198YpPGIrJXmuNHGolfPbrZIiwpD7bek0OiETxuphK3+KR5oJ5Qi1g5A==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/vitest/-/vitest-0.6.0.tgz} - name: vitest - version: 0.6.0 - engines: {node: '>=14.14.0'} - hasBin: true - peerDependencies: - '@vitest/ui': '*' - c8: '*' - happy-dom: '*' - jsdom: '*' - peerDependenciesMeta: - '@vitest/ui': - optional: true - c8: - optional: true - happy-dom: - optional: true - jsdom: - optional: true - dependencies: - '@types/chai': registry.npmmirror.com/@types/chai/4.3.0 - '@types/chai-subset': registry.npmmirror.com/@types/chai-subset/1.3.3 - chai: registry.npmmirror.com/chai/4.3.6 - local-pkg: registry.npmmirror.com/local-pkg/0.4.1 - tinypool: registry.npmmirror.com/tinypool/0.1.2 - tinyspy: registry.npmmirror.com/tinyspy/0.3.0 - vite: registry.npmmirror.com/vite/2.8.6 - transitivePeerDependencies: - - less - - sass - - stylus + fsevents: 2.3.2 dev: true diff --git a/samples/basic/test/fail_to_run.test.ts b/samples/basic/test/fail_to_run.test.ts new file mode 100644 index 00000000..3177eda9 --- /dev/null +++ b/samples/basic/test/fail_to_run.test.ts @@ -0,0 +1 @@ +test("aaaaaa", () => {}); diff --git a/src/TestData.ts b/src/TestData.ts index ea661b1e..0d775cbd 100644 --- a/src/TestData.ts +++ b/src/TestData.ts @@ -12,7 +12,7 @@ export type TestData = TestFile | TestDescribe | TestCase; export function getTestCaseId( childItem: vscode.TestItem, - name: string + name: string, ): string | undefined { const data = WEAKMAP_TEST_DATA.get(childItem); if (data instanceof TestDescribe || data instanceof TestCase) { @@ -28,7 +28,7 @@ export function getTestCaseId( export function getAllTestCases( item: vscode.TestItem, - agg: vscode.TestItem[] = [] + agg: vscode.TestItem[] = [], ) { if (item.children.size) { item.children.forEach((child) => { @@ -44,7 +44,7 @@ export class TestDescribe { constructor( public pattern: string, public fileItem: vscode.TestItem, - public parent: TestDescribe | TestFile + public parent: TestDescribe | TestFile, ) {} getFullPattern(): string { @@ -52,7 +52,7 @@ export class TestDescribe { } getFilePath(): string { - return this.fileItem.uri!.path; + return this.fileItem.uri!.fsPath; } } @@ -61,7 +61,7 @@ export class TestCase { public pattern: string, public fileItem: vscode.TestItem, public parent: TestDescribe | TestFile, - public index: number + public index: number, ) {} getFullPattern(): string { @@ -69,7 +69,7 @@ export class TestCase { } getFilePath(): string { - return this.fileItem.uri!.path; + return this.fileItem.uri!.fsPath; } } @@ -102,7 +102,7 @@ export class TestFile { } getFilePath(): string { - return this.item.uri!.path; + return this.item.uri!.fsPath; } } diff --git a/src/discover.ts b/src/discover.ts index 2fffc97b..a7162c76 100644 --- a/src/discover.ts +++ b/src/discover.ts @@ -1,4 +1,5 @@ import * as vscode from "vscode"; +import { sep } from "path"; import parse from "./pure/parsers"; import { NamedBlock } from "./pure/parsers/parser_nodes"; import { @@ -32,7 +33,7 @@ export class TestFileDiscoverer extends vscode.Disposable { this.workspaceCommonPrefix.clear(); }); this.workspacePaths = - vscode.workspace.workspaceFolders?.map((x) => x.uri.path) || []; + vscode.workspace.workspaceFolders?.map((x) => x.uri.fsPath) || []; } async discoverAllFilesInWorkspace( @@ -57,7 +58,7 @@ export class TestFileDiscoverer extends vscode.Disposable { ); const watcher = vscode.workspace.createFileSystemWatcher(pattern); const filter = (v: vscode.Uri) => - exclude.every((x) => !minimatch(v.path, x, { dot: true })); + exclude.every((x) => !minimatch(v.fsPath, x, { dot: true })); watcher.onDidCreate( (uri) => filter(uri) && this.getOrCreateFile(controller, uri), ); @@ -119,22 +120,22 @@ export class TestFileDiscoverer extends vscode.Disposable { } const workspacePath = this.workspacePaths.find((x) => - uri.path.startsWith(x) + uri.fsPath.startsWith(x) ); let name; if (workspacePath) { if (!this.workspaceCommonPrefix.has(workspacePath)) { - const path = uri.path.split("/"); + const path = uri.fsPath.split(sep); this.workspaceCommonPrefix.set( workspacePath, - path.slice(0, -1).join("/") + "/", + path.slice(0, -1).join(sep) + sep, ); this.workspaceItems.set(workspacePath, new Set()); } let workspacePrefix = this.workspaceCommonPrefix.get(workspacePath)!; - if (!uri.path.startsWith(workspacePrefix)) { - const p = uri.path; + if (!uri.fsPath.startsWith(workspacePrefix)) { + const p = uri.fsPath; for (let i = 0; i < workspacePrefix.length; i++) { if (p[i] !== workspacePrefix[i]) { workspacePrefix = workspacePrefix.slice(0, i); @@ -145,13 +146,13 @@ export class TestFileDiscoverer extends vscode.Disposable { this.workspaceCommonPrefix.set(workspacePath, workspacePrefix); const items = this.workspaceItems.get(workspacePath)!; items.forEach((v) => { - v.label = v.uri!.path.substring(workspacePrefix.length); + v.label = v.uri!.fsPath.substring(workspacePrefix.length); }); } - name = uri.path.substring(workspacePrefix.length); + name = uri.fsPath.substring(workspacePrefix.length); } else { - name = uri.path.split("/").pop()!; + name = uri.fsPath.split(sep).pop()!; } const file = controller.createTestItem(uri.toString(), name, uri); diff --git a/src/extension.ts b/src/extension.ts index 047d5e53..bf153379 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -12,7 +12,7 @@ export async function activate(context: vscode.ExtensionContext) { if ( vscode.workspace.workspaceFolders == null || vscode.workspace.workspaceFolders.length === 0 || - !(await isVitestEnv(vscode.workspace.workspaceFolders[0].uri.path)) + !(await isVitestEnv(vscode.workspace.workspaceFolders[0].uri.fsPath)) ) { return; } @@ -44,7 +44,7 @@ export async function activate(context: vscode.ExtensionContext) { }; const vitestPath = getVitestPath( - vscode.workspace.workspaceFolders[0].uri.path, + vscode.workspace.workspaceFolders[0].uri.fsPath, ); if (vitestPath != null) { const vitestVersion = await getVitestVersion(vitestPath); diff --git a/src/pure/isVitestEnv.ts b/src/pure/isVitestEnv.ts index c1dd59b0..1359d2fe 100644 --- a/src/pure/isVitestEnv.ts +++ b/src/pure/isVitestEnv.ts @@ -1,4 +1,3 @@ -import { execSync } from "child_process"; import { existsSync } from "fs"; import { readFile } from "fs-extra"; import path = require("path"); @@ -21,9 +20,9 @@ export async function isVitestEnv(projectRoot: string) { } return ( - execSync(path.join(projectRoot, "vite.config.js")) || - execSync(path.join(projectRoot, "vite.config.ts")) || - execSync(path.join(projectRoot, "vitest.config.js")) || - execSync(path.join(projectRoot, "vitest.config.ts")) + existsSync(path.join(projectRoot, "vite.config.js")) || + existsSync(path.join(projectRoot, "vite.config.ts")) || + existsSync(path.join(projectRoot, "vitest.config.js")) || + existsSync(path.join(projectRoot, "vitest.config.ts")) ); } diff --git a/src/pure/platform.ts b/src/pure/platform.ts new file mode 100644 index 00000000..2a2211dc --- /dev/null +++ b/src/pure/platform.ts @@ -0,0 +1,262 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +const LANGUAGE_DEFAULT = "en"; + +let _isWindows = false; +let _isMacintosh = false; +let _isLinux = false; +let _isLinuxSnap = false; +let _isNative = false; +let _isWeb = false; +let _isElectron = false; +let _isIOS = false; +let _locale: string | undefined = undefined; +let _language: string = LANGUAGE_DEFAULT; +let _translationsConfigFile: string | undefined = undefined; +let _userAgent: string | undefined = undefined; + +interface NLSConfig { + locale: string; + availableLanguages: { [key: string]: string }; + _translationsConfigFile: string; +} + +export interface IProcessEnvironment { + [key: string]: string | undefined; +} + +/** + * This interface is intentionally not identical to node.js + * process because it also works in sandboxed environments + * where the process object is implemented differently. We + * define the properties here that we need for `platform` + * to work and nothing else. + */ +export interface INodeProcess { + platform: string; + arch: string; + env: IProcessEnvironment; + versions?: { + electron?: string; + }; + sandboxed?: boolean; + type?: string; + cwd: () => string; +} + +declare const process: INodeProcess; +declare const global: unknown; +declare const self: unknown; + +// deno-lint-ignore no-explicit-any +export const globals: any = + (typeof self === "object" ? self : typeof global === "object" ? global : {}); + +let nodeProcess: INodeProcess | undefined = undefined; +if ( + typeof globals.vscode !== "undefined" && + typeof globals.vscode.process !== "undefined" +) { + // Native environment (sandboxed) + nodeProcess = globals.vscode.process; +} else if (typeof process !== "undefined") { + // Native environment (non-sandboxed) + nodeProcess = process; +} + +const isElectronProcess = typeof nodeProcess?.versions?.electron === "string"; +const isElectronRenderer = isElectronProcess && + nodeProcess?.type === "renderer"; +export const isElectronSandboxed = isElectronRenderer && nodeProcess?.sandboxed; + +interface INavigator { + userAgent: string; + language: string; + maxTouchPoints?: number; +} +declare const navigator: INavigator; + +// Web environment +if (typeof navigator === "object" && !isElectronRenderer) { + _userAgent = navigator.userAgent; + _isWindows = _userAgent.indexOf("Windows") >= 0; + _isMacintosh = _userAgent.indexOf("Macintosh") >= 0; + _isIOS = + (_userAgent.indexOf("Macintosh") >= 0 || _userAgent.indexOf("iPad") >= 0 || + _userAgent.indexOf("iPhone") >= 0) && + !!navigator.maxTouchPoints && navigator.maxTouchPoints > 0; + _isLinux = _userAgent.indexOf("Linux") >= 0; + _isWeb = true; + _locale = navigator.language; + _language = _locale; +} // Native environment +else if (typeof nodeProcess === "object") { + _isWindows = nodeProcess.platform === "win32"; + _isMacintosh = nodeProcess.platform === "darwin"; + _isLinux = nodeProcess.platform === "linux"; + _isLinuxSnap = _isLinux && !!nodeProcess.env["SNAP"] && + !!nodeProcess.env["SNAP_REVISION"]; + _isElectron = isElectronProcess; + _locale = LANGUAGE_DEFAULT; + _language = LANGUAGE_DEFAULT; + const rawNlsConfig = nodeProcess.env["VSCODE_NLS_CONFIG"]; + if (rawNlsConfig) { + try { + const nlsConfig: NLSConfig = JSON.parse(rawNlsConfig); + const resolved = nlsConfig.availableLanguages["*"]; + _locale = nlsConfig.locale; + // VSCode's default language is 'en' + _language = resolved ? resolved : LANGUAGE_DEFAULT; + _translationsConfigFile = nlsConfig._translationsConfigFile; + } catch (_e) { + // + } + } + _isNative = true; +} // Unknown environment +else { + console.error("Unable to resolve platform."); +} + +export const enum Platform { + Web, + Mac, + Linux, + Windows, +} +export function PlatformToString(platform: Platform) { + switch (platform) { + case Platform.Web: + return "Web"; + case Platform.Mac: + return "Mac"; + case Platform.Linux: + return "Linux"; + case Platform.Windows: + return "Windows"; + } +} + +let _platform: Platform = Platform.Web; +if (_isMacintosh) { + _platform = Platform.Mac; +} else if (_isWindows) { + _platform = Platform.Windows; +} else if (_isLinux) { + _platform = Platform.Linux; +} + +export const isWindows = _isWindows; +export const isMacintosh = _isMacintosh; +export const isLinux = _isLinux; +export const isLinuxSnap = _isLinuxSnap; +export const isNative = _isNative; +export const isElectron = _isElectron; +export const isWeb = _isWeb; +export const isIOS = _isIOS; +export const platform = _platform; +export const userAgent = _userAgent; + +/** + * The language used for the user interface. The format of + * the string is all lower case (e.g. zh-tw for Traditional + * Chinese) + */ +export const language = _language; + +export const Language = { + value(): string { + return language; + }, + + isDefaultVariant(): boolean { + if (language.length === 2) { + return language === "en"; + } else if (language.length >= 3) { + return language[0] === "e" && language[1] === "n" && language[2] === "-"; + } else { + return false; + } + }, + + isDefault(): boolean { + return language === "en"; + }, +}; + +/** + * The OS locale or the locale specified by --locale. The format of + * the string is all lower case (e.g. zh-tw for Traditional + * Chinese). The UI is not necessarily shown in the provided locale. + */ +export const locale = _locale; + +/** + * The translations that are available through language packs. + */ +export const translationsConfigFile = _translationsConfigFile; + +/** + * See https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#:~:text=than%204%2C%20then-,set%20timeout%20to%204,-. + * + * Works similarly to `setTimeout(0)` but doesn't suffer from the 4ms artificial delay + * that browsers set when the nesting level is > 5. + */ +export const setTimeout0 = (() => { + if (typeof globals.postMessage === "function" && !globals.importScripts) { + interface IQueueElement { + id: number; + callback: () => void; + } + const pending: IQueueElement[] = []; + globals.addEventListener("message", (e: any) => { + if (e.data && e.data.vscodeScheduleAsyncWork) { + for (let i = 0, len = pending.length; i < len; i++) { + const candidate = pending[i]; + if (candidate.id === e.data.vscodeScheduleAsyncWork) { + pending.splice(i, 1); + candidate.callback(); + return; + } + } + } + }); + let lastId = 0; + return (callback: () => void) => { + const myId = ++lastId; + pending.push({ + id: myId, + callback: callback, + }); + globals.postMessage({ vscodeScheduleAsyncWork: myId }, "*"); + }; + } + return (callback: () => void) => setTimeout(callback); +})(); + +export const enum OperatingSystem { + Windows = 1, + Macintosh = 2, + Linux = 3, +} +export const OS = + (_isMacintosh || _isIOS + ? OperatingSystem.Macintosh + : (_isWindows ? OperatingSystem.Windows : OperatingSystem.Linux)); + +let _isLittleEndian = true; +let _isLittleEndianComputed = false; +export function isLittleEndian(): boolean { + if (!_isLittleEndianComputed) { + _isLittleEndianComputed = true; + const test = new Uint8Array(2); + test[0] = 1; + test[1] = 2; + const view = new Uint16Array(test.buffer); + _isLittleEndian = view[0] === (2 << 8) + 1; + } + return _isLittleEndian; +} diff --git a/src/pure/runner.ts b/src/pure/runner.ts index c85f9b98..78d0f19e 100644 --- a/src/pure/runner.ts +++ b/src/pure/runner.ts @@ -1,15 +1,18 @@ import { spawn } from "child_process"; -import { existsSync, readFile } from "fs-extra"; +import { readFile } from "fs-extra"; import { tmpdir } from "os"; +import { existsSync } from "fs"; import * as path from "path"; import { chunksToLinesAsync } from "@rauschma/stringio"; +import { isWindows } from "./platform"; export function getDebuggerConfig() {} let i = 0; +const suffix = (0 | (Math.random() * 1000000)).toString(36); export function getTempPath(): string { - return path.join(tmpdir(), `vitest-report-${i++}.json`); + return path.join(tmpdir(), `vitest-report-${suffix}${i++}.json`); } type Status = "passed" | "failed" | "skipped" | "pending" | "todo" | "disabled"; @@ -69,6 +72,10 @@ export class TestRunner { ? [this.vitestPath] : ["npx", "vitest"], ): Promise { + if (isWindows) { + testFile = testFile?.map(adaptWindowsFilePath); + } + const path = getTempPath(); const command = vitestCommand[0]; const args = [ @@ -77,7 +84,7 @@ export class TestRunner { "--reporter=json", "--reporter=verbose", "--outputFile", - path, + isWindows ? `"${path.replace(/\\/g, "/")}"` : path, "--run", ] as string[]; if (testNamePattern) { @@ -94,6 +101,7 @@ export class TestRunner { cwd: workspacePath, stdio: ["ignore", "pipe", "pipe"], env, + shell: isWindows, }); for await (const line of chunksToLinesAsync(child.stdout)) { @@ -147,3 +155,11 @@ export async function getNodeVersion() { return line; } } + +export function adaptWindowsFilePath(path: string) { + if (!isWindows) { + return path; + } + + return path.replace(/\\/g, "/").replace(/^\w:/, ""); +} diff --git a/src/pure/utils.ts b/src/pure/utils.ts index d142e9f8..91e0b188 100644 --- a/src/pure/utils.ts +++ b/src/pure/utils.ts @@ -1,6 +1,7 @@ import { chunksToLinesAsync } from "@rauschma/stringio"; import { spawn } from "child_process"; import { existsSync } from "fs-extra"; +import { isWindows } from "./platform"; import * as path from "path"; export function getVitestPath(projectRoot: string): string | undefined { @@ -24,9 +25,16 @@ export function getVitestPath(projectRoot: string): string | undefined { } export async function getVitestVersion(vitestPath: string): Promise { - const process = spawn(vitestPath, ["-v"], { - stdio: ["ignore", "pipe", "pipe"], - }); + let process; + if (vitestPath.endsWith("js") && isWindows) { + process = spawn("node", [vitestPath, "-v"], { + stdio: ["ignore", "pipe", "pipe"], + }); + } else { + process = spawn(vitestPath, ["-v"], { + stdio: ["ignore", "pipe", "pipe"], + }); + } for await (const line of chunksToLinesAsync(process.stdout)) { process.kill(); diff --git a/src/runHandler.ts b/src/runHandler.ts index 5dd6e232..428d24c3 100644 --- a/src/runHandler.ts +++ b/src/runHandler.ts @@ -1,5 +1,6 @@ import * as vscode from "vscode"; import { + adaptWindowsFilePath, FormattedTestResults, getNodeVersion, getTempPath, @@ -15,6 +16,7 @@ import { import { getConfig } from "./config"; import { readFile } from "fs-extra"; import { existsSync } from "fs"; +import { isWindows } from "./pure/platform"; export async function runHandler( ctrl: vscode.TestController, @@ -29,8 +31,8 @@ export async function runHandler( } const runner = new TestRunner( - vscode.workspace.workspaceFolders[0].uri.path, - getVitestPath(vscode.workspace.workspaceFolders[0].uri.path), + vscode.workspace.workspaceFolders[0].uri.fsPath, + getVitestPath(vscode.workspace.workspaceFolders[0].uri.fsPath), ); const tests = request.include ?? gatherTestItems(ctrl.items); @@ -118,7 +120,10 @@ async function runTest( const pathToFile = new Map(); for (const file of fileItems) { - pathToFile.set(file.uri!.path, file); + pathToFile.set(file.uri!.fsPath, file); + if (isWindows) { + pathToFile.set(file.uri!.fsPath.replace(/\\/g, "/"), file); + } } let out; @@ -223,17 +228,16 @@ async function debugTest( name: "Debug Current Test File", autoAttachChildProcesses: true, skipFiles: ["/**", "**/node_modules/**"], - program: getVitestPath(workspaceFolder.uri.path), + program: getVitestPath(workspaceFolder.uri.fsPath), args: [] as string[], smartStep: true, - console: "integratedTerminal", }; const outputFilePath = getTempPath(); const testData = testItems.map((item) => WEAKMAP_TEST_DATA.get(item)!); config.args = [ "run", - ...new Set(testData.map((x) => x.getFilePath())), + ...new Set(testData.map((x) => x.getFilePath()).map(adaptWindowsFilePath)), testData.length === 1 ? "--testNamePattern" : "", testData.length === 1 ? testData[0].getFullPattern() : "", "--reporter=default",