Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT REVIEW] More module-ified compiler testing #51144

Closed
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
95274fb
Make a few changes to allow all code to be loaded as one project
jakebailey Jul 26, 2022
812331e
Explicitly reference ts namespace in tsserverlibrary
jakebailey Jul 26, 2022
863d0a0
CONVERSION STEP - unindent
jakebailey Oct 11, 2022
8480dd1
CONVERSION STEP - explicitify
jakebailey Oct 11, 2022
bab724b
CONVERSION STEP - stripNamespaces
jakebailey Oct 11, 2022
541e6af
CONVERSION STEP - inlineImports
jakebailey Oct 11, 2022
b82fb96
CONVERSION STEP - .git-ignore-blame-revs
jakebailey Oct 11, 2022
f8de0e7
Fix scripts to have CRLF newlines
jakebailey Oct 7, 2022
27007b4
Make processDiagnosticMessages generate a module
jakebailey May 26, 2022
2f8996f
Remove local ESLint rule one-namespace-per-file
jakebailey Sep 7, 2022
a330c00
Make current state lint-clean
jakebailey Sep 7, 2022
74b460e
Undo changes needed to load codebase into ts-morph
jakebailey Oct 3, 2022
6a1622c
Add JSDoc eslint rule
jakebailey Sep 24, 2022
f7db5bb
Fix all internal JSDoc comments
jakebailey Sep 7, 2022
58ca2d5
Convert require calls to imports
jakebailey May 27, 2022
0f84ad7
Remove typescriptServices project
jakebailey Sep 13, 2022
33fae66
Remove generation of protocol.d.ts
jakebailey Sep 28, 2022
d9d9c2f
Remove all files in lib before LKG
jakebailey Oct 5, 2022
c6a71de
Get test suites running
jakebailey May 31, 2022
bf4f6a1
Get entrypoints working
jakebailey Sep 2, 2022
9b39db0
Ensure all projects are listed in root tsconfig.json
jakebailey Sep 28, 2022
174aa54
Remove ref files from testRunner
jakebailey Sep 30, 2022
11fe713
Add build via esbuild
jakebailey Sep 13, 2022
5a99735
Add dts bundling
jakebailey Sep 2, 2022
b1eefde
Consolidate checks that test if the current environment is Node
jakebailey Sep 26, 2022
632c477
Add ts to globalThis for convenience during debugging
jakebailey Sep 30, 2022
87f96d9
Restore self-compilation using built compiler in CI tests
jakebailey Oct 3, 2022
26dd68f
Add a --bundle=false variant to CI
jakebailey Oct 5, 2022
8205c4d
Temporarily disable template literals
jakebailey Oct 5, 2022
c81df40
Use jsonc-parser instead of LKG compiler in build
jakebailey Oct 9, 2022
1ce53cd
Rename Gulpfile to Herebyfile for improved git diff
jakebailey Oct 9, 2022
d69f45d
Change build system to hereby
jakebailey Oct 9, 2022
8d90d31
Update baselines for corrected line endings in lib files
jakebailey Oct 10, 2022
add890f
Don't use needsUpdate for quick tasks
jakebailey Oct 10, 2022
f26b10a
Modernize localize script
jakebailey Oct 10, 2022
8507e37
Switch to faster XML parsing library for localize
jakebailey Oct 10, 2022
f57936f
Don't check needsUpdate for localize, now that it is fast
jakebailey Oct 10, 2022
1eeba39
Remove mkdirp
jakebailey Oct 10, 2022
8fc68d6
Add temporary gulp shim for testing
jakebailey Oct 11, 2022
157a893
Specify rootDir and outDir in tsconfig-base rather than in each tsconfig
jakebailey Oct 11, 2022
a6eb3d8
Backport changes from monaco-editor to createPlaygroundBuild
jakebailey Oct 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
ARG VARIANT="14-buster"
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}

RUN sudo -u node npm install -g gulp-cli
RUN sudo -u node npm install -g hereby
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"local/simple-indent": "error",
"local/debug-assert": "error",
"local/no-keywords": "error",
"local/one-namespace-per-file": "error",
"local/jsdoc-format": "error",

// eslint-plugin-import
"import/no-extraneous-dependencies": ["error", { "optionalDependencies": false }],
Expand Down
8 changes: 8 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# CONVERSION STEP - inlineImports
541e6af2be2cd94f699eaa4f92da9e08c3258117
# CONVERSION STEP - stripNamespaces
bab724bbe5506457be18c36bc206cfc68b4a706f
# CONVERSION STEP - explicitify
8480dd1fc2ca1323bd1cca6a6a97bc6dcd8f4844
# CONVERSION STEP - unindent
863d0a0127bc0d403db1b33c7174ed8f9f9a503c
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Thank you for submitting a pull request!
Please verify that:
* [ ] There is an associated issue in the `Backlog` milestone (**required**)
* [ ] Code is up-to-date with the `main` branch
* [ ] You've successfully run `gulp runtests` locally
* [ ] You've successfully run `hereby runtests` locally
* [ ] There are new or updated unit tests validating the change

Refer to CONTRIBUTING.MD for more details.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/accept-baselines-fix-lints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
git config user.name "TypeScript Bot"
npm install
git rm -r --quiet tests/baselines/reference :^tests/baselines/reference/docker :^tests/baselines/reference/user
gulp runtests-parallel --ci --fix || true
gulp baseline-accept
npx hereby runtests-parallel --ci --fix || true
npx hereby baseline-accept
git add ./src
git add ./tests/baselines/reference
git diff --cached
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ jobs:
- "*"
- lts/*
- lts/-1
bundle:
- "true"
include:
- node-version: "*"
bundle: "false"

steps:
- uses: actions/checkout@v3
Expand All @@ -32,7 +37,7 @@ jobs:
- run: npm ci

- name: Tests
run: npm test
run: npm run test -- --bundle=${{ matrix.bundle }}

lint:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -63,10 +68,10 @@ jobs:
run: npm install --no-save --no-package-lock playwright

- name: Build local
run: gulp local
run: npx hereby local

- name: Validate the browser can import TypeScript
run: gulp test-browser-integration
run: npx hereby test-browser-integration

misc:
runs-on: ubuntu-latest
Expand All @@ -80,7 +85,7 @@ jobs:
- run: npm ci

- name: Build scripts
run: gulp scripts
run: npx hereby scripts

- name: ESLint tests
run: gulp run-eslint-rules-tests
run: npx hereby run-eslint-rules-tests
2 changes: 1 addition & 1 deletion .github/workflows/new-release-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' tests/baselines/reference/api/tsserverlibrary.d.ts
sed -i -e 's/const version\(: string\)\{0,1\} = `${versionMajorMinor}.0-.*`/const version = `${versionMajorMinor}.0-${{ github.event.client_payload.core_tag || 'dev' }}`/g' src/compiler/corePublic.ts
npm ci
gulp LKG
npx hereby LKG
npm test
git diff
git add package.json
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
run: |
npm whoami
npm ci
gulp configure-nightly
gulp LKG
gulp runtests-parallel
gulp clean
npx hereby configure-nightly
npx hereby LKG
npx hereby runtests-parallel
npx hereby clean
npm publish --tag next
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
6 changes: 3 additions & 3 deletions .github/workflows/release-branch-artifact.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ jobs:
- name: Adding playwright
run: npm install --no-save --no-package-lock playwright
- name: Validate the browser can import TypeScript
run: gulp test-browser-integration
run: npx hereby test-browser-integration
- name: LKG, clean, and pack
run: |
gulp LKG
gulp clean
npx hereby LKG
npx hereby clean
npm pack ./
mv typescript-*.tgz typescript.tgz
- name: Upload built tarfile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/set-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' tests/baselines/reference/api/tsserverlibrary.d.ts
sed -i -e 's/const version\(: string\)\{0,1\} = .*;/const version = "${{ github.event.client_payload.package_version }}" as string;/g' src/compiler/corePublic.ts
npm ci
gulp LKG
npx hereby LKG
npm test
git diff
git add package.json
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-lkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
git config user.email "typescriptbot@microsoft.com"
git config user.name "TypeScript Bot"
npm ci
gulp LKG
npx hereby LKG
npm test
git diff
git add ./lib
Expand Down
5 changes: 2 additions & 3 deletions .vscode/launch.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"configurations": [
{
"type": "node",
"protocol": "inspector",
"request": "launch",
"name": "Mocha Tests (currently opened test)",
"runtimeArgs": ["--nolazy"],
Expand Down Expand Up @@ -48,15 +47,15 @@
"outFiles": [
"${workspaceRoot}/built/local/run.js"
],
"customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue",
"customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue"
},
{
// See: https://github.com/microsoft/TypeScript/wiki/Debugging-Language-Service-in-VS-Code
"type": "node",
"request": "attach",
"name": "Attach to VS Code TS Server via Port",
"processId": "${command:PickProcess}",
"customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue",
"customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue"
}
]
}
28 changes: 10 additions & 18 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"version": "2.0.0",
"tasks": [
{
"type": "gulp",
"label": "gulp: local",
"task": "local",
"label": "npm: build:compiler",
"type": "npm",
"script": "build:compiler",
"group": {
"kind": "build",
"isDefault": true
Expand All @@ -16,30 +16,22 @@
]
},
{
"type": "gulp",
"label": "gulp: tsc",
"task": "tsc",
"label": "npm: build:tests",
"type": "npm",
"script": "build:tests",
"group": "build",
"problemMatcher": [
"$tsc"
]
},
{
"type": "gulp",
"label": "gulp: tests",
"task": "tests",
"label": "gulp: tests", // Kept for backwards compat for old launch.json files.
"type": "npm",
"script": "build:tests",
"group": "build",
"problemMatcher": [
"$tsc"
]
},
{
"type": "gulp",
"task": "services",
"label": "gulp: services",
"problemMatcher": [
"$tsc"
],
}
]
}
}
66 changes: 33 additions & 33 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,42 +54,42 @@ In general, things we find useful when reviewing suggestions are:
2. A copy of the TypeScript code. See the next steps for instructions.
3. [Node](https://nodejs.org), which runs JavaScript locally. Current or LTS will both work.
4. An editor. [VS Code](https://code.visualstudio.com) is the best place to start for TypeScript.
5. The gulp command line tool, for building and testing changes. See the next steps for how to install it.
5. The hereby command line tool, for building and testing changes. See the next steps for how to install it.

## Get Started

1. Install node using the version you downloaded from [nodejs.org](https://nodejs.org).
2. Open a terminal.
3. Make a fork—your own copy—of TypeScript on your GitHub account, then make a clone—a local copy—on your computer. ([Here are some step-by-step instructions](https://github.com/anitab-org/mentorship-android/wiki/Fork%2C-Clone-%26-Remote)). Add `--depth=1` to the end of the `git clone` command to save time.
4. Install the gulp command line tool: `npm install -g gulp-cli`
4. Install the hereby command line tool: `npm install -g hereby`
5. Change to the TypeScript folder you made: `cd TypeScript`
6. Install dependencies: `npm ci`
7. Make sure everything builds and tests pass: `gulp runtests-parallel`
7. Make sure everything builds and tests pass: `hereby runtests-parallel`
8. Open the TypeScript folder in your editor.
9. Follow the directions below to add and debug a test.

## Helpful tasks

Running `gulp --tasks --depth 1` provides the full listing, but here are a few common tasks you might use.
Running `hereby --tasks` provides the full listing, but here are a few common tasks you might use.

```
gulp local # Build the compiler into built/local.
gulp clean # Delete the built compiler.
gulp LKG # Replace the last known good with the built one.
# Bootstrapping step to be executed when the built compiler reaches a stable state.
gulp tests # Build the test infrastructure using the built compiler.
gulp runtests # Run tests using the built compiler and test infrastructure.
# You can override the specific suite runner used or specify a test for this command.
# Use --tests=<testPath> for a specific test and/or --runner=<runnerName> for a specific suite.
# Valid runners include conformance, compiler, fourslash, project, user, and docker
# The user and docker runners are extended test suite runners - the user runner
# works on disk in the tests/cases/user directory, while the docker runner works in containers.
# You'll need to have the docker executable in your system path for the docker runner to work.
gulp runtests-parallel # Like runtests, but split across multiple threads. Uses a number of threads equal to the system
# core count by default. Use --workers=<number> to adjust this.
gulp baseline-accept # This replaces the baseline test results with the results obtained from gulp runtests.
gulp lint # Runs eslint on the TypeScript source.
gulp help # List the above commands.
hereby local # Build the compiler into built/local.
hereby clean # Delete the built compiler.
hereby LKG # Replace the last known good with the built one.
# Bootstrapping step to be executed when the built compiler reaches a stable state.
hereby tests # Build the test infrastructure using the built compiler.
hereby runtests # Run tests using the built compiler and test infrastructure.
# You can override the specific suite runner used or specify a test for this command.
# Use --tests=<testPath> for a specific test and/or --runner=<runnerName> for a specific suite.
# Valid runners include conformance, compiler, fourslash, project, user, and docker
# The user and docker runners are extended test suite runners - the user runner
# works on disk in the tests/cases/user directory, while the docker runner works in containers.
# You'll need to have the docker executable in your system path for the docker runner to work.
hereby runtests-parallel # Like runtests, but split across multiple threads. Uses a number of threads equal to the system
# core count by default. Use --workers=<number> to adjust this.
hereby baseline-accept # This replaces the baseline test results with the results obtained from hereby runtests.
hereby lint # Runs eslint on the TypeScript source.
hereby help # List the above commands.
```

## Tips
Expand All @@ -111,7 +111,7 @@ You might need to run `git config --global core.longpaths true` before cloning T

### Using local builds

Run `gulp` to build a version of the compiler/language service that reflects changes you've made. You can then run `node <repo-root>/built/local/tsc.js` in place of `tsc` in your project. For example, to run `tsc --watch` from within the root of the repository on a file called `test.ts`, you can run `node ./built/local/tsc.js --watch test.ts`.
Run `hereby` to build a version of the compiler/language service that reflects changes you've made. You can then run `node <repo-root>/built/local/tsc.js` in place of `tsc` in your project. For example, to run `tsc --watch` from within the root of the repository on a file called `test.ts`, you can run `node ./built/local/tsc.js --watch test.ts`.

## Contributing bug fixes

Expand Down Expand Up @@ -163,7 +163,7 @@ Any changes should be made to [src/lib](https://github.com/Microsoft/TypeScript/
Library files in `built/local/` are updated automatically by running the standard build task:

```sh
gulp
hereby
```

The files in `lib/` are used to bootstrap compilation and usually **should not** be updated unless publishing a new version or updating the LKG.
Expand All @@ -178,36 +178,36 @@ If you need a head start understanding how the compiler works, or how the code i

## Running the Tests

To run all tests, invoke the `runtests-parallel` target using gulp:
To run all tests, invoke the `runtests-parallel` target using hereby:

```Shell
gulp runtests-parallel
hereby runtests-parallel
```

This will run all tests; to run only a specific subset of tests, use:

```Shell
gulp runtests --tests=<regex>
hereby runtests --tests=<regex>
```

e.g. to run all compiler baseline tests:

```Shell
gulp runtests --tests=compiler
hereby runtests --tests=compiler
```

or to run a specific test: `tests\cases\compiler\2dArrays.ts`

```Shell
gulp runtests --tests=2dArrays
hereby runtests --tests=2dArrays
```

## Debugging the tests

You can debug with VS Code or Node instead with `gulp runtests -i`:
You can debug with VS Code or Node instead with `hereby runtests -i`:

```Shell
gulp runtests --tests=2dArrays -i
hereby runtests --tests=2dArrays -i
```

You can also use the [provided VS Code launch configuration](./.vscode/launch.template.json) to launch a debug session for an open test file. Rename the file 'launch.json', open the test file of interest, and launch the debugger from the debug panel (or press F5).
Expand Down Expand Up @@ -257,12 +257,12 @@ When a change in the baselines is detected, the test will fail. To inspect chang
git diff --diff-filter=AM --no-index ./tests/baselines/reference ./tests/baselines/local
```

Alternatively, you can set the `DIFF` environment variable and run `gulp diff`, or manually run your favorite folder diffing tool between `tests/baselines/reference` and `tests/baselines/local`. Our team largely uses Beyond Compare and WinMerge.
Alternatively, you can set the `DIFF` environment variable and run `hereby diff`, or manually run your favorite folder diffing tool between `tests/baselines/reference` and `tests/baselines/local`. Our team largely uses Beyond Compare and WinMerge.

After verifying that the changes in the baselines are correct, run

```Shell
gulp baseline-accept
hereby baseline-accept
```

This will change the files in `tests\baselines\reference`, which should be included as part of your commit.
Expand All @@ -271,6 +271,6 @@ Be sure to validate the changes carefully -- apparently unrelated changes to bas
## Localization

All strings the user may see are stored in [`diagnosticMessages.json`](./src/compiler/diagnosticMessages.json).
If you make changes to it, run `gulp generate-diagnostics` to push them to the `Diagnostic` interface in `diagnosticInformationMap.generated.ts`.
If you make changes to it, run `hereby generate-diagnostics` to push them to the `Diagnostic` interface in `diagnosticInformationMap.generated.ts`.

See [coding guidelines on diagnostic messages](https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines#diagnostic-messages).
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ FROM node:current
COPY . /typescript
WORKDIR /typescript
RUN npm ci
RUN npm i -g gulp-cli
RUN gulp configure-insiders && gulp LKG && gulp clean && npm pack .
RUN npx hereby configure-insiders && npx hereby LKG && npx hereby clean && npm pack .
1 change: 1 addition & 0 deletions Gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
throw new Error("Do not use; run hereby instead.");
Loading