Skip to content

Commit d0a7a2a

Browse files
committed
test: split tests into integration and unit
1 parent 16001d7 commit d0a7a2a

15 files changed

+116
-65
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,11 +648,14 @@
648648
"watch-dev": "webpack --mode development --watch --progress",
649649
"webpack": "webpack --mode production",
650650
"pretest": "npm run compile-dev && tsc -p tsconfig.test.json",
651-
"test": "node ./out/test/runTest.js; npm run format",
651+
"test": "npm run test:unit && npm run test:integration",
652+
"test:unit": "node ./out/test/unitTest/runTest.js",
653+
"test:integration": "node ./out/test/integration/runTest.js",
652654
"test:grammar-free": "vscode-tmgrammar-snap -s source.fortran.free -g ./syntaxes/fortran_free-form.tmLanguage.json \"./test/fortran/syntax/**/*{.f90,F90}\"",
653655
"test:grammar-fixed": "vscode-tmgrammar-snap -s source.fortran.fixed -g ./syntaxes/fortran_fixed-form.tmLanguage.json \"./test/fortran/syntax/**/*{.f,F}\"",
654656
"test:grammar": "npm run test:grammar-free && npm run test:grammar-fixed",
655657
"test:grammar-update": "npm run test:grammar-free -- -u && npm run test:grammar-fixed -- -u",
658+
"posttest": "npm run format",
656659
"lint": "eslint . --ext .ts,.tsx",
657660
"lint-fix": "npm run lint -- --fix",
658661
"format": "prettier --write 'src/**/*.{ts,json}' 'test/**/*.ts' 'syntaxes/**/*.json' 'snippets/**/*.json' './**/*.{md,json,yaml,yml}'",

test/extension.test.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.
File renamed without changes.

test/lsp-client.test.ts renamed to test/integration/lsp-client.test.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
import * as vscode from 'vscode';
22
import * as path from 'path';
33
import { strictEqual } from 'assert';
4-
import { FortlsClient } from '../src/lsp/client';
5-
import { delay } from '../src/lib/helper';
6-
import { Logger, LogLevel } from '../src/services/logging';
4+
import { FortlsClient } from '../../src/lsp/client';
5+
import { delay } from '../../src/lib/helper';
6+
import { Logger, LogLevel } from '../../src/services/logging';
77

88
const logger = new Logger(
99
vscode.window.createOutputChannel('Modern Fortran', 'log'),
1010
LogLevel.DEBUG
1111
);
1212

1313
suite('Language Server integration tests', () => {
14-
let doc: vscode.TextDocument;
1514
const server = new FortlsClient(logger);
16-
const fileUri = vscode.Uri.file(
17-
path.resolve(__dirname, '../../test/fortran/function_subroutine_definitions.f90')
18-
);
15+
const fileUri = vscode.Uri.file(path.resolve(__dirname, '../../../test/fortran/sample.f90'));
1916

20-
suiteSetup(async function (): Promise<void> {
21-
await server.activate();
17+
suiteSetup(async () => {
18+
const doc = await vscode.workspace.openTextDocument(fileUri);
19+
await vscode.window.showTextDocument(doc);
2220
});
2321

2422
test('Launch fortls & Check Initialization Response', async () => {
23+
await server.activate();
2524
await delay(3000); // wait for server to initialize
26-
doc = await vscode.workspace.openTextDocument(fileUri);
27-
await vscode.window.showTextDocument(doc);
2825

2926
const ref = {
3027
capabilities: {

test/runTest.ts renamed to test/integration/runTest.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ async function main() {
99
const results = spawnSync(`pip`, [
1010
'install',
1111
'-r',
12-
path.resolve(__dirname, '../../test/requirements.txt'),
12+
path.resolve(__dirname, '../../../test/requirements.txt'),
1313
'--force',
1414
'--upgrade',
1515
]);
@@ -20,8 +20,8 @@ async function main() {
2020
console.log(results.stdout.toString().trim());
2121
// The folder containing the Extension Manifest package.json
2222
// Passed to `--extensionDevelopmentPath`
23-
const extensionDevelopmentPath = path.resolve(__dirname, '../../');
24-
const workspacePath = path.resolve(__dirname, '../../test/fortran/');
23+
const extensionDevelopmentPath = path.resolve(__dirname, '../../../');
24+
const workspacePath = path.resolve(__dirname, '../../../test/fortran/');
2525

2626
// The path to the extension test runner script
2727
// Passed to --extensionTestsPath
File renamed without changes.
File renamed without changes.

test/formatting-provider.test.ts renamed to test/unitTest/formatting-provider.test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { strictEqual } from 'assert';
2-
import { FortranFormattingProvider } from '../src/features/formatting-provider';
2+
import { FortranFormattingProvider } from '../../src/features/formatting-provider';
33
import * as vscode from 'vscode';
44
import * as path from 'path';
5-
import { Logger, LogLevel } from '../src/services/logging';
5+
import { Logger, LogLevel } from '../../src/services/logging';
66

77
const logger = new Logger(
88
vscode.window.createOutputChannel('Modern Fortran', 'log'),
@@ -13,13 +13,12 @@ suite('Formatting tests', () => {
1313
let doc: vscode.TextDocument;
1414
const fmt = new FortranFormattingProvider(logger);
1515
const fileUri = vscode.Uri.file(
16-
path.resolve(__dirname, '../../test/fortran/format/formatting_test.f90')
16+
path.resolve(__dirname, '../../../test/fortran/format/formatting_test.f90')
1717
);
1818

1919
suiteSetup(async function (): Promise<void> {
2020
doc = await vscode.workspace.openTextDocument(fileUri);
2121
await vscode.window.showTextDocument(doc);
22-
console.log('Open file: ' + fileUri.toString());
2322
});
2423

2524
test('Using findent', async () => {
@@ -66,7 +65,7 @@ end program main
6665
vscode.Uri.file(
6766
path.resolve(
6867
__dirname,
69-
'../../test/fortran/format/formatting_test_fprettify_long_lines.f90'
68+
'../../../test/fortran/format/formatting_test_fprettify_long_lines.f90'
7069
)
7170
)
7271
);

test/functions.test.ts renamed to test/unitTest/functions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
// The module 'assert' provides assertion methods from node
77
import * as assert from 'assert';
8-
import { validVariableName, parseFunction, parseArgs } from '../src/lib/functions';
8+
import { validVariableName, parseFunction, parseArgs } from '../../src/lib/functions';
99

1010
suite('function helper test', () => {
1111
test('validVariableName does not allow variables starting with number', () => {

test/helper.test.ts renamed to test/unitTest/helper.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
isArrayOfString,
1111
arraysEqual,
1212
isPositionInString,
13-
} from '../src/lib/helper';
13+
} from '../../src/lib/helper';
1414
import * as vscode from 'vscode';
1515

1616
suite('helper functions isTypeVariable tests', () => {

0 commit comments

Comments
 (0)