Skip to content

Commit c410e03

Browse files
jboldaamrbashir
andauthored
convert jest tests to child_process run script (#2308)
* convert jest tests to child_process run script * remove vuecli (it freezes), add angular * run cargo build in correct dir * add in asserts on fs * normalize assert for node14 * fix installing empty dependencies * add messages to asserts * use test dir to check if running local cli * try running in parallel * run in parallel and log output serially * avoid parallel, skip yarn for now * add change file * disable running with npm6 due to vite fail Co-authored-by: amrbashir <48618675+amrbashir@users.noreply.github.com>
1 parent 63ad303 commit c410e03

8 files changed

Lines changed: 1074 additions & 2728 deletions

File tree

.changes/cta-test-script.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"create-tauri-app": patch
3+
"cli.js": patch
4+
---
5+
6+
Adjust check for `dev` mode and switch CTA test to a script runner. The script gives us more control and better output into any failures.

.github/workflows/test-cta.yml

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
# SPDX-License-Identifier: MIT
44

55
name: test create-tauri-app
6+
env:
7+
RUST_BACKTRACE: 1
8+
TAURI_RECIPE: 'vanillajs,cra,vite,ngcli'
69

710
on:
811
workflow_dispatch:
@@ -13,20 +16,16 @@ on:
1316
paths:
1417
- "tooling/create-tauri-app/**"
1518

16-
env:
17-
RUST_BACKTRACE: 1
18-
1919
jobs:
2020
create-recipe-with-npm:
21-
name: "node@${{ matrix.node }} + npm@${{ matrix.manager }}: ${{ matrix.recipe }}"
21+
name: "node@${{ matrix.node }} + npm@${{ matrix.manager }}"
2222
runs-on: ${{ github.event.inputs.platform || 'ubuntu' }}-latest
2323

2424
strategy:
2525
fail-fast: false
2626
matrix:
2727
node: ["14", "16"]
28-
manager: ["6", "7"]
29-
recipe: ["vanillajs", "cra", "vite", "ngcli", "svelte", "dominator"]
28+
manager: ["7"]
3029
exclude:
3130
- node: "16"
3231
manager: "6"
@@ -62,40 +61,37 @@ jobs:
6261
- run: yarn test
6362
working-directory: tooling/create-tauri-app
6463
env:
65-
TAURI_RECIPE: ${{ matrix.recipe }}
6664
TAURI_RUN_MANAGER: "npm"
6765

68-
create-recipe-with-yarn:
69-
name: "node@${{ matrix.node }} + yarn@1: ${{ matrix.recipe }}"
70-
runs-on: ${{ github.event.inputs.platform || 'ubuntu' }}-latest
66+
# create-recipe-with-yarn:
67+
# name: "node@${{ matrix.node }} + yarn@1"
68+
# runs-on: ${{ github.event.inputs.platform || 'ubuntu' }}-latest
7169

72-
strategy:
73-
fail-fast: false
74-
matrix:
75-
node: ["14", "16"]
76-
recipe: ["vanillajs", "cra", "vite", "ngcli", "svelte"]
70+
# strategy:
71+
# fail-fast: false
72+
# matrix:
73+
# node: ["14", "16"]
7774

78-
steps:
79-
- uses: actions/checkout@v2
80-
- name: install stable
81-
uses: actions-rs/toolchain@v1
82-
with:
83-
toolchain: stable
84-
- uses: volta-cli/action@v1
85-
with:
86-
node-version: ${{ matrix.node }}
87-
yarn-version: 1.22.5
88-
- name: install webkit2gtk
89-
if: (github.event.inputs.platform || 'ubuntu') == 'ubuntu'
90-
run: |
91-
sudo apt-get update
92-
sudo apt-get install -y libgtk-3-dev libgtksourceview-3.0-dev webkit2gtk-4.0 libappindicator3-dev
93-
- run: yarn
94-
working-directory: tooling/create-tauri-app
95-
- run: yarn build
96-
working-directory: tooling/create-tauri-app
97-
- run: yarn test
98-
working-directory: tooling/create-tauri-app
99-
env:
100-
TAURI_RECIPE: ${{ matrix.recipe }}
101-
TAURI_RUN_MANAGER: "yarn"
75+
# steps:
76+
# - uses: actions/checkout@v2
77+
# - name: install stable
78+
# uses: actions-rs/toolchain@v1
79+
# with:
80+
# toolchain: stable
81+
# - uses: volta-cli/action@v1
82+
# with:
83+
# node-version: ${{ matrix.node }}
84+
# yarn-version: 1.22.5
85+
# - name: install webkit2gtk
86+
# if: (github.event.inputs.platform || 'ubuntu') == 'ubuntu'
87+
# run: |
88+
# sudo apt-get update
89+
# sudo apt-get install -y libgtk-3-dev libgtksourceview-3.0-dev webkit2gtk-4.0 libappindicator3-dev
90+
# - run: yarn
91+
# working-directory: tooling/create-tauri-app
92+
# - run: yarn build
93+
# working-directory: tooling/create-tauri-app
94+
# - run: yarn test
95+
# working-directory: tooling/create-tauri-app
96+
# env:
97+
# TAURI_RUN_MANAGER: "yarn"

tooling/cli.js/src/helpers/rust-cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export async function runOnRustCli(
5757
onClose
5858
)
5959
} else {
60-
if (existsSync(resolve(targetPath, '../bundler'))) {
61-
// running local CLI
60+
if (existsSync(resolve(targetPath, 'test'))) {
61+
// running local CLI since test directory exists
6262
const cliPath = resolve(targetPath, '../cli.rs')
6363
spawnSync('cargo', ['build', '--release'], cliPath)
6464
const localCliPath = resolve(

tooling/create-tauri-app/package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"lint:lockfile": "lockfile-lint --path yarn.lock --type yarn --validate-https --allowed-hosts npm yarn",
3030
"format": "prettier --write --end-of-line=auto \"./**/*.{cjs,js,jsx,ts,tsx,html,css,json}\" --ignore-path .gitignore",
3131
"format:check": "prettier --check --end-of-line=auto \"./**/*.{cjs,js,jsx,ts,tsx,html,css,json}\" --ignore-path .gitignore",
32-
"test": "jest --runInBand"
32+
"test": "node ./test/spawn.test.mjs"
3333
},
3434
"dependencies": {
3535
"chalk": "4.1.1",
@@ -39,16 +39,17 @@
3939
"scaffe": "1.1.0"
4040
},
4141
"devDependencies": {
42+
"@effection/process": "2.0.0-beta.8",
4243
"@rollup/plugin-commonjs": "19.0.0",
4344
"@rollup/plugin-node-resolve": "13.0.0",
4445
"@rollup/plugin-typescript": "8.2.1",
4546
"@types/cross-spawn": "6.0.2",
4647
"@types/inquirer": "7.3.1",
47-
"@types/jest": "26.0.23",
4848
"@types/minimist": "1.2.1",
4949
"@types/semver": "7.3.6",
5050
"@typescript-eslint/eslint-plugin": "4.25.0",
5151
"@typescript-eslint/parser": "4.25.0",
52+
"effection": "2.0.0-beta.8",
5253
"eslint": "7.27.0",
5354
"eslint-config-prettier": "8.3.0",
5455
"eslint-config-standard-with-typescript": "20.0.0",
@@ -57,11 +58,9 @@
5758
"eslint-plugin-node": "11.1.0",
5859
"eslint-plugin-promise": "5.1.0",
5960
"eslint-plugin-security": "1.4.0",
60-
"fixturez": "1.1.0",
61-
"jest": "27.0.3",
6261
"prettier": "2.3.0",
6362
"rollup": "2.50.4",
64-
"ts-jest": "27.0.1",
63+
"temp-dir": "^2.0.0",
6564
"tslib": "2.2.0",
6665
"typescript": "4.3.2"
6766
}

tooling/create-tauri-app/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ const runInit = async (argv: Argv): Promise<void> => {
368368
logStep(`Updating ${reset(yellow('"package.json"'))}`)
369369
updatePackageJson(appDirectory, appName)
370370

371-
logStep(`Running: ${reset(yellow('tauri init'))}`)
371+
logStep(`Running ${reset(yellow('"tauri init"'))}`)
372372
const binary = !argv.b ? packageManager : resolve(appDirectory, argv.b)
373373
// pnpm is equivalent to yarn and can run srcipts without using "run" but due to this bug https://github.com/pnpm/pnpm/issues/2764
374374
// we need to pass "--" to pnpm or arguments won't be parsed correctly so for this command only we are gonna treat pnpm as npm equivalent/

tooling/create-tauri-app/test/index.spec.ts

Lines changed: 0 additions & 169 deletions
This file was deleted.

0 commit comments

Comments
 (0)