Skip to content

Commit b8ddab7

Browse files
committed
Merge branch 'main' into bdougie/anthropic-prompt-true
2 parents 9a429c7 + 557963d commit b8ddab7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1726
-8031
lines changed

.github/workflows/pr_checks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ jobs:
439439
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
440440
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
441441
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
442-
AZURE_FOUNDRY_API_KEY: ${{ secrets.AZURE_FOUNDRY_API_KEY }}
442+
AZURE_FOUNDRY_CODESTRAL_API_KEY: ${{ secrets.AZURE_FOUNDRY_CODESTRAL_API_KEY }}
443443
AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY: ${{ secrets.AZURE_FOUNDRY_MISTRAL_SMALL_API_KEY }}
444444
AZURE_OPENAI_GPT41_API_KEY: ${{ secrets.AZURE_OPENAI_GPT41_API_KEY }}
445445

core/autocomplete/context/root-path-context/test/RootPathContextService.test.ts renamed to core/autocomplete/context/root-path-context/test/RootPathContextService.vitest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, test } from "vitest";
12
import { PYTHON_TEST_CASES, TYPESCRIPT_TEST_CASES } from "./testCases";
23
import { testRootPathContext } from "./testUtils";
34

core/autocomplete/context/root-path-context/test/testUtils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { jest } from "@jest/globals";
21
import fs from "fs";
32
import path from "path";
3+
import { expect, vi } from "vitest";
44

55
import Parser from "web-tree-sitter";
66
import { Position } from "../../../..";
@@ -36,7 +36,7 @@ export async function testRootPathContext(
3636
const importDefinitionsService = new ImportDefinitionsService(ide);
3737
const service = new RootPathContextService(importDefinitionsService, ide);
3838

39-
const getSnippetsMock = jest
39+
const getSnippetsMock = vi
4040
// @ts-ignore
4141
.spyOn(service, "getSnippets")
4242
// @ts-ignore
@@ -46,7 +46,7 @@ export async function testRootPathContext(
4646

4747
// Copy the folder to the test directory
4848
const folderPath = path.join(
49-
__dirname,
49+
process.cwd(),
5050
"autocomplete",
5151
"context",
5252
"root-path-context",

core/autocomplete/filtering/streamTransforms/charStream.test.ts renamed to core/autocomplete/filtering/streamTransforms/charStream.vitest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, expect, it } from "vitest";
12
import { stopAtStartOf, stopAtStopTokens } from "./charStream";
23

34
async function* createMockStream(chunks: string[]): AsyncGenerator<string> {

core/autocomplete/filtering/streamTransforms/lineStream.test.ts renamed to core/autocomplete/filtering/streamTransforms/lineStream.vitest.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { jest } from "@jest/globals";
1+
import { beforeEach, describe, expect, it, Mock, vi } from "vitest";
22

33
import * as lineStream from "./lineStream";
44

55
// eslint-disable-next-line max-lines-per-function
66
describe("lineStream", () => {
7-
let mockFullStop: jest.Mock;
7+
let mockFullStop: Mock;
88

99
async function getLineGenerator(lines: any) {
1010
return (async function* () {
@@ -25,7 +25,7 @@ describe("lineStream", () => {
2525
}
2626

2727
beforeEach(() => {
28-
mockFullStop = jest.fn();
28+
mockFullStop = vi.fn();
2929
});
3030

3131
describe("noTopLevelKeywordsMidline", () => {

core/autocomplete/filtering/test/filter.test.ts renamed to core/autocomplete/filtering/test/filter.vitest.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { setUpTestDir, tearDownTestDir } from "../../../test/testDir";
1+
import { afterAll, beforeAll, beforeEach, describe, it } from "vitest";
2+
import {
3+
addToTestDir,
4+
setUpTestDir,
5+
tearDownTestDir,
6+
} from "../../../test/testDir";
27

38
import { TEST_CASES_WITH_DIFF, TEST_CASES_WITHOUT_DIFF } from "./testCases";
49
import {
@@ -18,6 +23,7 @@ describe("Autocomplete filtering tests", () => {
1823
beforeAll(async () => {
1924
tearDownTestDir();
2025
setUpTestDir();
26+
addToTestDir([".continueignore"]);
2127
});
2228

2329
afterAll(async () => {

core/autocomplete/filtering/test/util.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { expect } from "vitest";
12
import MockLLM from "../../../llm/llms/Mock";
23
import { testConfigHandler, testIde } from "../../../test/fixtures";
34
import { joinPathsToUri } from "../../../util/uri";

core/autocomplete/generation/GeneratorReuseManager.test.ts renamed to core/autocomplete/generation/GeneratorReuseManager.vitest.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { jest } from "@jest/globals";
1+
import {
2+
afterEach,
3+
beforeEach,
4+
describe,
5+
expect,
6+
Mock,
7+
test,
8+
vi,
9+
} from "vitest";
210
import { GeneratorReuseManager } from "./GeneratorReuseManager";
311

412
function createMockGenerator(
@@ -14,7 +22,7 @@ function createMockGenerator(
1422
}
1523
}
1624
};
17-
const newGenerator = jest
25+
const newGenerator = vi
1826
.fn<() => AsyncGenerator<string>>()
1927
.mockReturnValue(mockGenerator());
2028

@@ -23,15 +31,15 @@ function createMockGenerator(
2331

2432
describe("GeneratorReuseManager", () => {
2533
let reuseManager: GeneratorReuseManager;
26-
let onErrorMock: jest.Mock;
34+
let onErrorMock: Mock;
2735

2836
beforeEach(() => {
29-
onErrorMock = jest.fn();
37+
onErrorMock = vi.fn();
3038
reuseManager = new GeneratorReuseManager(onErrorMock);
3139
});
3240

3341
afterEach(() => {
34-
jest.clearAllMocks();
42+
vi.clearAllMocks();
3543
});
3644

3745
test("creates new generator when there is no current generator", async () => {
@@ -169,7 +177,7 @@ describe("GeneratorReuseManager", () => {
169177
const mockGenerator = async function* () {
170178
throw error;
171179
};
172-
const newGenerator = jest
180+
const newGenerator = vi
173181
.fn<() => AsyncGenerator<string>>()
174182
.mockReturnValue(mockGenerator());
175183

core/autocomplete/generation/ListenableGenerator.test.ts renamed to core/autocomplete/generation/ListenableGenerator.vitest.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { jest } from "@jest/globals";
1+
import { describe, expect, it, vi } from "vitest";
22

33
import { ListenableGenerator } from "./ListenableGenerator";
44

@@ -16,7 +16,7 @@ describe("ListenableGenerator", () => {
1616
it("should yield values from the source generator via tee()", async () => {
1717
const values = [1, 2, 3];
1818
const source = asyncGenerator(values);
19-
const onError = jest.fn();
19+
const onError = vi.fn();
2020

2121
const lg = new ListenableGenerator<number>(
2222
source,
@@ -36,15 +36,15 @@ describe("ListenableGenerator", () => {
3636
it("should allow listeners to receive values", async () => {
3737
const values = [1, 2, 3];
3838
const source = asyncGenerator(values, 10); // Introduce delay to simulate async behavior
39-
const onError = jest.fn();
39+
const onError = vi.fn();
4040

4141
const lg = new ListenableGenerator<number>(
4242
source,
4343
onError,
4444
new AbortController(),
4545
);
4646

47-
const listener = jest.fn();
47+
const listener = vi.fn();
4848

4949
// Add listener after some delay to simulate late subscription
5050
setTimeout(() => {
@@ -64,23 +64,23 @@ describe("ListenableGenerator", () => {
6464
it("should buffer values for listeners added after some values have been yielded", async () => {
6565
const values = [1, 2, 3];
6666
const source = asyncGenerator(values, 10);
67-
const onError = jest.fn();
67+
const onError = vi.fn();
6868

6969
const lg = new ListenableGenerator<number>(
7070
source,
7171
onError,
7272
new AbortController(),
7373
);
7474

75-
const initialListener = jest.fn();
75+
const initialListener = vi.fn();
7676

7777
lg.listen(initialListener);
7878

7979
// Wait for the first value to be yielded
8080
await new Promise((resolve) => setTimeout(resolve, 15));
8181

8282
// Add a second listener
83-
const newListener = jest.fn();
83+
const newListener = vi.fn();
8484
lg.listen(newListener);
8585

8686
// Wait for generator to finish
@@ -98,7 +98,7 @@ describe("ListenableGenerator", () => {
9898
it("should handle cancellation", async () => {
9999
const values = [1, 2, 3, 4, 5];
100100
const source = asyncGenerator(values, 10);
101-
const onError = jest.fn();
101+
const onError = vi.fn();
102102

103103
const lg = new ListenableGenerator<number>(
104104
source,
@@ -131,7 +131,7 @@ describe("ListenableGenerator", () => {
131131
}
132132

133133
const source = errorGenerator();
134-
const onError = jest.fn();
134+
const onError = vi.fn();
135135

136136
const lg = new ListenableGenerator<number>(
137137
source,
@@ -152,15 +152,15 @@ describe("ListenableGenerator", () => {
152152
it("should notify listeners when the generator ends", async () => {
153153
const values = [1, 2, 3];
154154
const source = asyncGenerator(values);
155-
const onError = jest.fn();
155+
const onError = vi.fn();
156156

157157
const lg = new ListenableGenerator<number>(
158158
source,
159159
onError,
160160
new AbortController(),
161161
);
162162

163-
const listener = jest.fn();
163+
const listener = vi.fn();
164164
lg.listen(listener);
165165

166166
// Wait for the generator to finish

core/autocomplete/generation/utils.test.ts renamed to core/autocomplete/generation/utils.vitest.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { jest } from "@jest/globals";
1+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
22
import { stopAfterMaxProcessingTime } from "./utils";
33

44
describe("stopAfterMaxProcessingTime", () => {
55
beforeEach(() => {
6-
jest.useFakeTimers();
6+
vi.useFakeTimers();
77
});
88

99
afterEach(() => {
10-
jest.useRealTimers();
10+
vi.useRealTimers();
1111
});
1212

1313
async function* createMockStream(chunks: string[]): AsyncGenerator<string> {
@@ -28,7 +28,7 @@ describe("stopAfterMaxProcessingTime", () => {
2828

2929
it("should yield all chunks when maxTimeMs is not reached", async () => {
3030
const mockStream = createMockStream(["Hello", " world", "!"]);
31-
const fullStop = jest.fn();
31+
const fullStop = vi.fn();
3232
const result = stopAfterMaxProcessingTime(mockStream, 1000, fullStop);
3333

3434
const output = await streamToString(result);
@@ -37,11 +37,11 @@ describe("stopAfterMaxProcessingTime", () => {
3737
expect(fullStop).not.toHaveBeenCalled();
3838
});
3939

40-
it.only("should stop processing after max time is reached", async () => {
40+
it("should stop processing after max time is reached", async () => {
4141
// Mock implementation of Date.now
4242
let currentTime = 0;
4343
const originalDateNow = Date.now;
44-
Date.now = jest.fn(() => currentTime);
44+
Date.now = vi.fn(() => currentTime);
4545

4646
// Create a generator that we can control
4747
async function* controlledGenerator(): AsyncGenerator<string> {
@@ -54,7 +54,7 @@ describe("stopAfterMaxProcessingTime", () => {
5454
}
5555
}
5656

57-
const fullStop = jest.fn();
57+
const fullStop = vi.fn();
5858
const maxTimeMs = 500;
5959

6060
const transformedGenerator = stopAfterMaxProcessingTime(
@@ -84,10 +84,10 @@ describe("stopAfterMaxProcessingTime", () => {
8484
it("should check time only periodically based on checkInterval", async () => {
8585
const chunks = Array(100).fill("x");
8686
const mockStream = createMockStream(chunks);
87-
const fullStop = jest.fn();
87+
const fullStop = vi.fn();
8888

8989
// Spy on Date.now to count how many times it's called
90-
const dateSpy = jest.spyOn(Date, "now");
90+
const dateSpy = vi.spyOn(Date, "now");
9191

9292
// Stream should complete normally (not hitting the timeout)
9393
await streamToString(
@@ -105,7 +105,7 @@ describe("stopAfterMaxProcessingTime", () => {
105105

106106
it("should handle empty stream gracefully", async () => {
107107
const mockStream = createMockStream([]);
108-
const fullStop = jest.fn();
108+
const fullStop = vi.fn();
109109
const result = stopAfterMaxProcessingTime(mockStream, 1000, fullStop);
110110

111111
const output = await streamToString(result);
@@ -117,7 +117,7 @@ describe("stopAfterMaxProcessingTime", () => {
117117
it("should pass through all chunks if there's no timeout", async () => {
118118
const chunks = Array(100).fill("test chunk");
119119
const mockStream = createMockStream(chunks);
120-
const fullStop = jest.fn();
120+
const fullStop = vi.fn();
121121

122122
// Use undefined as timeout to simulate no timeout
123123
const result = stopAfterMaxProcessingTime(

core/autocomplete/snippets/gitDiffCache.test.ts renamed to core/autocomplete/snippets/gitDiffCache.vitest.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { beforeEach, expect, test, vi } from "vitest";
12
import { GitDiffCache } from "./gitDiffCache";
23

34
beforeEach(() => {
@@ -7,7 +8,7 @@ beforeEach(() => {
78

89
test("GitDiffCache returns cached results within cache time", async () => {
910
const mockDiff = ["file1.ts", "file2.ts"];
10-
const getDiffFn = jest.fn().mockResolvedValue(mockDiff);
11+
const getDiffFn = vi.fn().mockResolvedValue(mockDiff);
1112
const cache = GitDiffCache.getInstance(getDiffFn, 1); // 1 second cache
1213

1314
const result1 = await cache.get();
@@ -20,7 +21,7 @@ test("GitDiffCache returns cached results within cache time", async () => {
2021

2122
test("GitDiffCache refreshes cache after expiration", async () => {
2223
const mockDiff = ["file1.ts"];
23-
const getDiffFn = jest.fn().mockResolvedValue(mockDiff);
24+
const getDiffFn = vi.fn().mockResolvedValue(mockDiff);
2425
const cache = GitDiffCache.getInstance(getDiffFn, 0.1); // 100ms cache
2526

2627
const result1 = await cache.get();
@@ -31,7 +32,7 @@ test("GitDiffCache refreshes cache after expiration", async () => {
3132
});
3233

3334
test("GitDiffCache returns empty array on error", async () => {
34-
const getDiffFn = jest.fn().mockRejectedValue(new Error("Git error"));
35+
const getDiffFn = vi.fn().mockRejectedValue(new Error("Git error"));
3536
const cache = GitDiffCache.getInstance(getDiffFn);
3637

3738
const result = await cache.get();
@@ -41,7 +42,7 @@ test("GitDiffCache returns empty array on error", async () => {
4142
test("GitDiffCache reuses pending request", async () => {
4243
const mockDiff = ["file1.ts"];
4344
let resolvePromise: (value: string[]) => void;
44-
const getDiffFn = jest.fn().mockImplementation(() => {
45+
const getDiffFn = vi.fn().mockImplementation(() => {
4546
return new Promise((resolve) => {
4647
resolvePromise = resolve;
4748
});
@@ -63,7 +64,7 @@ test("GitDiffCache reuses pending request", async () => {
6364

6465
test("GitDiffCache invalidate clears cache", async () => {
6566
const mockDiff = ["file1.ts"];
66-
const getDiffFn = jest.fn().mockResolvedValue(mockDiff);
67+
const getDiffFn = vi.fn().mockResolvedValue(mockDiff);
6768
const cache = GitDiffCache.getInstance(getDiffFn);
6869

6970
await cache.get();
@@ -74,8 +75,8 @@ test("GitDiffCache invalidate clears cache", async () => {
7475
});
7576

7677
test("GitDiffCache maintains singleton instance", () => {
77-
const getDiffFn1 = jest.fn();
78-
const getDiffFn2 = jest.fn();
78+
const getDiffFn1 = vi.fn();
79+
const getDiffFn2 = vi.fn();
7980

8081
const instance1 = GitDiffCache.getInstance(getDiffFn1);
8182
const instance2 = GitDiffCache.getInstance(getDiffFn2);

core/autocomplete/templating/__tests__/formatOpenedFilesContext.test.ts renamed to core/autocomplete/templating/__tests__/formatOpenedFilesContext.vitest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*
44
*/
55

6+
import { describe, expect, test } from "vitest";
67
import {
78
AutocompleteCodeSnippet,
89
AutocompleteDiffSnippet,

core/autocomplete/util/completionTestUtils.test.ts renamed to core/autocomplete/util/completionTestUtils.vitest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, expect, it } from "vitest";
12
import {
23
processTestCase,
34
type CompletionTestCase,

core/autocomplete/util/processSingleLineCompletion.test.ts renamed to core/autocomplete/util/processSingleLineCompletion.vitest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { describe, expect, it } from "vitest";
12
import { processTestCase } from "./completionTestUtils";
23
import { processSingleLineCompletion } from "./processSingleLineCompletion";
34

0 commit comments

Comments
 (0)