Skip to content

Commit 8f5c736

Browse files
committed
chore: move tests folder to top level
1 parent 521ea74 commit 8f5c736

File tree

8 files changed

+13
-12
lines changed

8 files changed

+13
-12
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Setup Node
1818
uses: actions/setup-node@v4
1919
with:
20-
node-version: 16
20+
node-version: 18
2121
- name: Install deps
2222
run: npm install
2323
- name: Install vsce

scripts/test/integration-test.cjs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ const path = require('node:path')
22
const Mocha = require('mocha')
33
const glob = require('glob')
44

5+
const TESTS_ROOT = path.join(__dirname, '../../tests')
6+
57
async function run() {
68
await import('tsx')
79
// Create the mocha test
@@ -13,7 +15,7 @@ async function run() {
1315
})
1416

1517
/**
16-
Before any other tests, run the testSetup.ts file
18+
Before any other tests, run the testSetup.ts file
1719
This will set up the test environment necessary for the other tests to run
1820
*/
1921
mocha.addFile(path.join(__dirname, 'testSetup.ts'))
@@ -25,14 +27,13 @@ async function run() {
2527
* So you could play with sort order on the tests to investigate
2628
*/
2729
try {
28-
const testsRoot = path.join(__dirname, '../../src/test')
29-
let files = await glob('**.test.ts', { cwd: testsRoot })
30+
let files = await glob('**.test.ts', { cwd: TESTS_ROOT })
3031
// Add files to the test suite
3132
files.sort((a, b) => {
3233
return a.localeCompare(b)
3334
})
3435
files.forEach(f => {
35-
mocha.addFile(path.resolve(testsRoot, f))
36+
mocha.addFile(path.resolve(TESTS_ROOT, f))
3637
})
3738

3839
return new Promise((resolve, reject) => {

scripts/test/testSetup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { activate } from '../../src/test/utils'
1+
import { activate } from '../../tests/utils'
22
/**
33
* This initialization runs once, before the rest of the tests.
44
* It is used to open the test fixture folder and activate the extension.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/test/utils.ts renamed to tests/utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import * as assert from 'assert'
55
export let doc: vscode.TextDocument
66
export let editor: vscode.TextEditor
77

8+
const FIXTURE_PATH = path.resolve(__dirname, '../fixture')
9+
810
/**
911
* Prepare the vscode environment for testing by opening the fixture folder
1012
* and activating the extension.
@@ -15,9 +17,7 @@ export let editor: vscode.TextEditor
1517
export async function activate() {
1618
// The extensionId is `publisher.name` from package.json
1719
const ext = vscode.extensions.getExtension('ast-grep.ast-grep-vscode')!
18-
const fixtureFolderUri = vscode.Uri.file(
19-
path.resolve(__dirname, '../../fixture')
20-
)
20+
const fixtureFolderUri = vscode.Uri.file(FIXTURE_PATH)
2121
await ext.activate()
2222
try {
2323
// open ast-grep project to locate sgconfig.yml
@@ -118,7 +118,7 @@ async function sleep(ms: number) {
118118
}
119119

120120
export const getDocPath = (p: string) => {
121-
return path.resolve(__dirname, '../../fixture', p)
121+
return path.resolve(FIXTURE_PATH, p)
122122
}
123123
export const getDocUri = (p: string) => {
124124
return vscode.Uri.file(getDocPath(p))

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
"target": "es2020",
55
"lib": ["es2020", "DOM"],
66
"outDir": "out",
7-
"rootDir": "src",
7+
"rootDir": ".",
88
"esModuleInterop": true,
99
"forceConsistentCasingInFileNames": true,
1010
"strict": true,
1111
"sourceMap": true,
1212
"skipLibCheck": true,
1313
"jsx": "react-jsx"
1414
},
15-
"include": ["src"],
15+
"include": ["src", "tests"],
1616
"exclude": ["node_modules", ".vscode-test"]
1717
}

0 commit comments

Comments
 (0)