Skip to content

Commit b10a2df

Browse files
committed
Don't let interactor file interfere with the states
1 parent c3b1de5 commit b10a2df

File tree

2 files changed

+25
-43
lines changed

2 files changed

+25
-43
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
- Seed for generators in stress tester not utilizing full 64-bit integer range
2525
- Tooltip not updating when the attribute changes
2626
- Compilation errors being double logged resulting in unhandled promise rejections
27+
- Interactor file compiling prematurely setting status of the testcase
2728

2829
### Removed
2930

src/extension/providers/JudgeViewProvider.ts

Lines changed: 24 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,38 @@ export default class extends BaseViewProvider<typeof ProviderMessageSchema, Webv
150150
return null;
151151
}
152152

153-
const compilePromises = [this._compileIfNeeded(id, token, this._currentFile, testcase)];
153+
super._postMessage({
154+
type: "SET",
155+
id,
156+
property: "status",
157+
value: "COMPILING",
158+
});
159+
160+
const compilePromises = [compile(this._currentFile!, this._context)];
154161
if (testcase.mode === "interactive") {
155-
compilePromises.push(this._compileIfNeeded(id, token, settings.interactorFile!, testcase));
162+
compilePromises.push(compile(settings.interactorFile!, this._context));
156163
}
157164
const errored = await Promise.all(compilePromises);
158165
const anyErrored = errored.some((hadError) => hadError);
159166
if (anyErrored) {
167+
testcase.status = "CE";
168+
super._postMessage({
169+
type: "SET",
170+
id,
171+
property: "status",
172+
value: "CE",
173+
});
160174
return null;
161175
}
162176

177+
testcase.status = "NA";
178+
super._postMessage({
179+
type: "SET",
180+
id,
181+
property: "status",
182+
value: "NA",
183+
});
184+
163185
let interactorArgs: string[] | null = null;
164186
if (testcase.mode === "interactive") {
165187
const interactorSettings = getFileRunSettings(settings.interactorFile!);
@@ -192,47 +214,6 @@ export default class extends BaseViewProvider<typeof ProviderMessageSchema, Webv
192214
};
193215
}
194216

195-
private async _compileIfNeeded(
196-
id: number,
197-
token: vscode.CancellationToken,
198-
file: string,
199-
testcase: State
200-
): Promise<boolean> {
201-
const compilePromise = compile(file, this._context);
202-
if (!compilePromise) {
203-
return true;
204-
}
205-
206-
super._postMessage({
207-
type: "SET",
208-
id,
209-
property: "status",
210-
value: "COMPILING",
211-
});
212-
213-
if (!token.isCancellationRequested && (await compilePromise)) {
214-
testcase.status = "CE";
215-
super._postMessage({
216-
type: "SET",
217-
id,
218-
property: "status",
219-
value: "CE",
220-
});
221-
this._saveFileData();
222-
return true;
223-
} else {
224-
testcase.status = "NA";
225-
super._postMessage({
226-
type: "SET",
227-
id,
228-
property: "status",
229-
value: "NA",
230-
});
231-
}
232-
233-
return token.isCancellationRequested;
234-
}
235-
236217
private _prepareRunningState(id: number, testcase: State) {
237218
super._postMessage({
238219
type: "SET",

0 commit comments

Comments
 (0)