Skip to content

Commit 0ffc4be

Browse files
author
guomingliang
committed
fix:update 4.3.0
1 parent f64f05d commit 0ffc4be

37 files changed

+488
-198
lines changed

other/hbuilderx-autotest/common/utils.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
export declare function monitorProcess(pid: number): Promise<{
2+
pid: number;
3+
memory: string;
4+
cpu: string;
5+
t: Date;
6+
} | undefined>;
7+
export declare function hxTsserverProcesses(): any[];
18
export declare function getLocalIP(): string;
29
export declare function purgeCache(moduleName: string): any;
310
export declare const getInitTestFile: (fileOrProjectKey: string) => string;
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
import { Position, Range } from 'vscode-languageserver';
2+
interface AutoTestCase<T> {
3+
kind: string;
4+
title: string;
5+
tag?: string;
6+
expect: T;
7+
error?: {
8+
message: string;
9+
cause: string;
10+
};
11+
}
12+
interface KeybindingExpect {
13+
/**
14+
* apply之后对应的函内容匹配
15+
*/
16+
lines: string[] | RegExp[];
17+
/**
18+
* apply之后对应的光标位置
19+
*/
20+
cursor?: Position;
21+
}
22+
interface AutoTestKeybindCase extends AutoTestCase<KeybindingExpect> {
23+
kind: 'keybind';
24+
range: Range;
25+
input: string;
26+
typeInNewLine?: boolean;
27+
keybind: string;
28+
}
29+
interface AutoTestCheckEditorCase extends AutoTestCase<KeybindingExpect> {
30+
kind: 'checkEditor';
31+
}
32+
interface AutoEditExpect {
33+
/**
34+
* apply之后对应的函内容匹配
35+
*/
36+
lines: string[] | RegExp[];
37+
/**
38+
* apply之后对应的光标位置
39+
*/
40+
cursor?: Position;
41+
}
42+
interface AutoTestAutoEditCase extends AutoTestCase<AutoEditExpect> {
43+
kind: 'autoedit';
44+
range: Range;
45+
typeInNewLine?: boolean;
46+
input: string;
47+
}
48+
interface DefinitionExpect {
49+
continueAfterjumping: any;
50+
uri: string;
51+
line: string | RegExp;
52+
cursor?: number;
53+
}
54+
interface AutoTestDefinitionCase extends AutoTestCase<DefinitionExpect> {
55+
kind: 'definition';
56+
continueAfterjumping?: boolean;
57+
range: Range;
58+
}
59+
interface HoverExpect {
60+
/**
61+
* hover的内容
62+
*/
63+
content: string | RegExp;
64+
/**
65+
* 是否支持F1打开帮助文档
66+
*/
67+
supportF1?: boolean;
68+
}
69+
interface AutoTestHoverCase extends AutoTestCase<HoverExpect> {
70+
kind: 'hover' | 'noerror' | 'error';
71+
range: Range;
72+
docOffsetAt: number;
73+
type: 'string';
74+
}
75+
interface OutlineExpect {
76+
filePath: string;
77+
}
78+
interface AutoTestOutlineCase extends AutoTestCase<OutlineExpect> {
79+
kind: 'outline';
80+
needCreate?: boolean;
81+
project: string;
82+
lsDir: string;
83+
programData: string;
84+
programPlugin: string;
85+
}
86+
interface FormatExpect {
87+
filePath: string;
88+
}
89+
interface AutoTestFormatCase extends AutoTestCase<FormatExpect> {
90+
kind: 'format';
91+
needCreate?: boolean;
92+
project: string;
93+
lsDir: string;
94+
programData: string;
95+
programPlugin: string;
96+
}
97+
interface FoldExpect {
98+
filePath: string;
99+
}
100+
interface AutoTestFoldCase extends AutoTestCase<FoldExpect> {
101+
kind: 'fold';
102+
needCreate?: boolean;
103+
project: string;
104+
lsDir: string;
105+
programData: string;
106+
programPlugin: string;
107+
}
108+
interface OpenFileExpect {
109+
uri: string;
110+
}
111+
interface AutoTestOpenFileCase extends AutoTestCase<OpenFileExpect> {
112+
}
113+
interface ReferencesExpect {
114+
filePath: string;
115+
}
116+
interface AutoTestReferencesCase extends AutoTestCase<ReferencesExpect> {
117+
kind: 'references';
118+
needCreate?: boolean;
119+
range: Range;
120+
docOffsetAt: number;
121+
project: string;
122+
lsDir: string;
123+
programData: string;
124+
programPlugin: string;
125+
}
126+
interface SameWordExpect {
127+
filePath: string;
128+
}
129+
interface AutoTestSameWordCase extends AutoTestCase<SameWordExpect> {
130+
kind: 'sameWord';
131+
needCreate?: boolean;
132+
range: Range;
133+
docOffsetAt: number;
134+
project: string;
135+
lsDir: string;
136+
programData: string;
137+
programPlugin: string;
138+
}
139+
interface CommandExpect {
140+
lines: string[] | RegExp[];
141+
cursor?: Position;
142+
}
143+
interface AutoTestCommandCase extends AutoTestCase<CommandExpect> {
144+
kind: 'command';
145+
range: Range;
146+
typeInNewLine?: boolean;
147+
command: string;
148+
}
149+
interface ErrorExpect {
150+
content: string | RegExp;
151+
}
152+
interface CompletionExpect {
153+
/**
154+
* 代码助手列表项
155+
*/
156+
items: string[];
157+
/**
158+
* 代码助手列表项-不能包含项
159+
*/
160+
excludeItems: string[];
161+
/**
162+
* apply之后对应的行内容匹配
163+
*/
164+
lines: string[] | RegExp[];
165+
/**
166+
* apply之后对应的光标位置
167+
*/
168+
cursor?: Position;
169+
/**
170+
* apply的item的详细信息
171+
*/
172+
detail?: string | RegExp;
173+
}
174+
interface AutoTestCompletionCase extends AutoTestCase<CompletionExpect> {
175+
kind: 'completion' | 'init';
176+
/**
177+
* 是否在新的一行写,如为true,则会在range位置回车后开始写
178+
*/
179+
typeInNewLine?: boolean;
180+
/**
181+
* 要输入的位置
182+
*/
183+
range: Range;
184+
/**
185+
* 要输入的文字
186+
*/
187+
input: string;
188+
/**
189+
* 选择哪一项,默认是第一项。下标从`0`开始
190+
*/
191+
applyIndex?: number;
192+
}
193+
interface AutoTestRetriggerCase extends AutoTestCase<CompletionExpect> {
194+
kind: 'retrigger';
195+
typeInNewLine?: boolean;
196+
range: Range;
197+
input: string;
198+
applyIndex?: number;
199+
}
200+
interface AutoTestDbClickCase extends AutoTestCase<DbClickExpect> {
201+
kind: 'dbclick';
202+
range: Range;
203+
}
204+
interface DbClickExpect {
205+
begin: string;
206+
end: string;
207+
match: string;
208+
}
209+
interface PerformanceExpect {
210+
expect: AutoTestDefinitionCase | AutoTestHoverCase | AutoTestCompletionCase;
211+
}
212+
interface AutoTestPerformanceCase extends AutoTestCase<PerformanceExpect> {
213+
kind: 'performance';
214+
type: string;
215+
num: number;
216+
timer: number;
217+
range: Range;
218+
}
219+
export { AutoEditExpect, AutoTestAutoEditCase, AutoTestCase, AutoTestCheckEditorCase, AutoTestCompletionCase, AutoTestDbClickCase, AutoTestDefinitionCase, AutoTestFoldCase, AutoTestFormatCase, AutoTestHoverCase, AutoTestKeybindCase, AutoTestOpenFileCase, AutoTestOutlineCase, AutoTestPerformanceCase, AutoTestReferencesCase, AutoTestRetriggerCase, AutoTestSameWordCase, AutoTestCommandCase, CommandExpect, CompletionExpect, DbClickExpect, DefinitionExpect, ErrorExpect, FoldExpect, FormatExpect, HoverExpect, KeybindingExpect, OpenFileExpect, OutlineExpect, PerformanceExpect, ReferencesExpect, SameWordExpect, };
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { AutoTestCase } from '../autoTestHandler/autoTestDef';
2+
import { ParseData } from './utils';
3+
declare function parseAllCase(parseData: ParseData): AutoTestCase<any> | false;
4+
export { parseAllCase };
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { ParseData } from '../utils';
2+
declare function parseCommand(parseData: ParseData): import("../autoTestDef").AutoTestCase<any>;
3+
export { parseCommand };
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { ParseData } from '../utils';
2+
declare function parseCompletion(parseData: ParseData): import("../../autoTestHandler/autoTestDef").AutoTestCase<any>;
3+
export { parseCompletion };
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { ParseData } from '../utils';
2+
declare function parseDbClick(parseData: ParseData): import("../autoTestDef").AutoTestCase<any>;
3+
export { parseDbClick };
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { ParseData } from '../utils';
2+
declare function parseDefinition(parseData: ParseData): import("../autoTestDef").AutoTestCase<any>;
3+
export { parseDefinition };
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { ParseData } from '../utils';
2+
declare function parseHover(parseData: ParseData): import("../autoTestDef").AutoTestCase<any>;
3+
export { parseHover };
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { ParseData } from '../utils';
2+
declare function parseKeybind(parseData: ParseData): import("../autoTestDef").AutoTestCase<any>;
3+
export { parseKeybind };
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { AutoTestCase } from '../autoTestDef';
2+
import { ParseData } from '../utils';
3+
declare function parseOpenFile(parseData: ParseData): AutoTestCase<any>;
4+
export { parseOpenFile };
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { AutoTestOutlineCase } from "../autoTestDef";
2+
import { ParseData } from "../utils";
3+
declare function parseOutLine(parseData: ParseData): AutoTestOutlineCase;
4+
export { parseOutLine };
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { ParseData } from '../utils';
2+
declare function parsePerformance(parseData: ParseData): false | import("../autoTestDef").AutoTestCase<any>;
3+
export { parsePerformance };
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { ParseData } from '../utils';
2+
declare function parseReferences(parseData: ParseData): import("../autoTestDef").AutoTestCase<any>;
3+
export { parseReferences };
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { Position, Range } from 'vscode-languageserver';
2+
import { TextDocument, TextDocumentLine } from '../editor';
3+
import { AutoTestCase } from './autoTestDef';
4+
interface ParseData {
5+
kind: string;
6+
doc: TextDocument;
7+
i: number;
8+
line: TextDocumentLine;
9+
title: string;
10+
tag: string;
11+
input: any;
12+
expect: any;
13+
project: string;
14+
lsDir: string;
15+
programData: string;
16+
programPlugin: string;
17+
config: any;
18+
generateScan: any;
19+
}
20+
/**
21+
* 匹配测试用例
22+
*/
23+
declare function matchTestcaseContent(line: string): string | undefined;
24+
/**
25+
* 获取下一个非注释行
26+
* @param from
27+
* @param doc
28+
* @returns
29+
*/
30+
declare function nextNonCommentLine(from: number, doc: TextDocument): TextDocumentLine | undefined;
31+
/**
32+
* 下一行
33+
*/
34+
declare function prevTestcaseLine(from: number, doc: TextDocument): number;
35+
/**
36+
* 创建输入匹配错误
37+
* @param details
38+
* @returns
39+
*/
40+
declare function createInputMatchError(details: ParseData): AutoTestCase<any>;
41+
/**
42+
* 解析输入范围
43+
* @param parseData
44+
* @param nextLine
45+
* @returns
46+
*/
47+
declare function parseInputRange(parseData: ParseData, nextLine: TextDocumentLine): {
48+
range: Range;
49+
docOffsetAt: number;
50+
} | undefined;
51+
declare function parseClickRange(parseData: ParseData, nextLine: TextDocumentLine): Range | undefined;
52+
declare function parseLines(parseData: ParseData, inputLine: number): {
53+
expectLines: string[] | RegExp[];
54+
expectCursor: Position | undefined;
55+
};
56+
export { createInputMatchError, parseLines, matchTestcaseContent, nextNonCommentLine, parseClickRange, ParseData, parseInputRange, prevTestcaseLine, };

0 commit comments

Comments
 (0)