* allow setting apiBase for bedrock provider * ⚡️ better linking * ✨ new prompt file action * ⚡️ strip <COMPLETION> from GPT-4 completion * continue proxy FIM support * warn user if potentially dangerous command is generated * tab autocomplete docs * docs: update PR template (#1531) * chore: add docs to install script (#1533) * fix(extensions): schema for db ctx provider (#1534) * fix(extensions): schema for db ctx provider * fix: invalid enum * prettierignore * docs: add docs and schema for "OS" provider (#1536) * tests (#1501) * 👷 CI for jetbrains * default working dir * changelog * build binaries * binary testing setup * idesettings * core binary testing * run binary tests in ci * remove unused targets * needs build * console.log bin contents * fix ci * fix win32 binary download * test * no linux arm64 * macos latest * macos-12 * binary permissions * upload logs * fix * upload full folder as binary artifact * test * test macos only * set full execute permissions * copy sqlite binary * cd * it worked! * build again in test job * debug * remove timeout * info * log * log2 * more logs * catch * fewer logs * test all platforms * test downloaded artifact * needs build * updates * build * false * release * add tag and upload binaryes * change tag name * proper artifact upload * jest updates * ✅ generate a few unit tests with Continue * fix imports related to IdeSettings * run tsc on PRs * remove shareSession command (unused) * update release process * update plugin version * don't show ghost text when jetbrains completion visible * run jetbrains ci in main * check ts in dev * ignore .env * 🚑 fix constant warnings when onboarding with Ollama --------- Co-authored-by: Patrick Erichsen <patrick.a.erichsen@gmail.com>
137 lines
3.7 KiB
TypeScript
137 lines
3.7 KiB
TypeScript
import { FromIdeProtocol, ToIdeProtocol } from "core/protocol/index.js";
|
|
import FileSystemIde from "core/util/filesystem";
|
|
import { IMessenger } from "core/util/messenger";
|
|
import { ReverseMessageIde } from "core/util/reverseMessageIde";
|
|
import fs from "fs";
|
|
import { ChildProcessWithoutNullStreams, spawn } from "node:child_process";
|
|
import path from "path";
|
|
import {
|
|
CoreBinaryMessenger,
|
|
CoreBinaryTcpMessenger,
|
|
} from "../src/IpcMessenger";
|
|
|
|
// jest.setTimeout(100_000);
|
|
|
|
const USE_TCP = false;
|
|
|
|
function autodetectPlatformAndArch() {
|
|
const platform = {
|
|
aix: "linux",
|
|
darwin: "darwin",
|
|
freebsd: "linux",
|
|
linux: "linux",
|
|
openbsd: "linux",
|
|
sunos: "linux",
|
|
win32: "win32",
|
|
android: "linux",
|
|
cygwin: "win32",
|
|
netbsd: "linux",
|
|
haiku: "linux",
|
|
}[process.platform];
|
|
const arch = {
|
|
arm: "arm64",
|
|
arm64: "arm64",
|
|
ia32: "x64",
|
|
loong64: "arm64",
|
|
mips: "arm64",
|
|
mipsel: "arm64",
|
|
ppc: "x64",
|
|
ppc64: "x64",
|
|
riscv64: "arm64",
|
|
s390: "x64",
|
|
s390x: "x64",
|
|
x64: "x64",
|
|
}[process.arch];
|
|
return [platform, arch];
|
|
}
|
|
|
|
const CONTINUE_GLOBAL_DIR = path.join(__dirname, "..", ".continue");
|
|
|
|
describe("Test Suite", () => {
|
|
let messenger: IMessenger<ToIdeProtocol, FromIdeProtocol>;
|
|
let subprocess: ChildProcessWithoutNullStreams;
|
|
|
|
beforeAll(async () => {
|
|
const [platform, arch] = autodetectPlatformAndArch();
|
|
const binaryPath = path.join(
|
|
__dirname,
|
|
"..",
|
|
"bin",
|
|
`${platform}-${arch}`,
|
|
`continue-binary${platform === "win32" ? ".exe" : ""}`,
|
|
);
|
|
expect(fs.existsSync(binaryPath)).toBe(true);
|
|
|
|
if (USE_TCP) {
|
|
messenger = new CoreBinaryTcpMessenger<ToIdeProtocol, FromIdeProtocol>();
|
|
} else {
|
|
subprocess = spawn(binaryPath, {
|
|
env: { ...process.env, CONTINUE_GLOBAL_DIR },
|
|
});
|
|
messenger = new CoreBinaryMessenger<ToIdeProtocol, FromIdeProtocol>(
|
|
subprocess,
|
|
);
|
|
}
|
|
|
|
const ide = new FileSystemIde();
|
|
const reverseIde = new ReverseMessageIde(messenger.on.bind(messenger), ide);
|
|
|
|
// Wait for core to set itself up
|
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
});
|
|
|
|
afterAll(async () => {
|
|
// Wait for the subprocess to exit
|
|
if (USE_TCP) {
|
|
(
|
|
messenger as CoreBinaryTcpMessenger<ToIdeProtocol, FromIdeProtocol>
|
|
).close();
|
|
} else {
|
|
subprocess.kill();
|
|
await new Promise((resolve) => subprocess.on("close", resolve));
|
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
}
|
|
});
|
|
|
|
it("should respond to ping with pong", async () => {
|
|
const resp = await messenger.request("ping", "ping");
|
|
expect(resp).toBe("pong");
|
|
});
|
|
|
|
it("should create .continue directory at the specified location with expected files", async () => {
|
|
expect(fs.existsSync(CONTINUE_GLOBAL_DIR)).toBe(true);
|
|
|
|
// Many of the files are only created when trying to load the config
|
|
const config = await messenger.request(
|
|
"config/getBrowserSerialized",
|
|
undefined,
|
|
);
|
|
|
|
const expectedFiles = [
|
|
"config.json",
|
|
"config.ts",
|
|
"package.json",
|
|
"logs/core.log",
|
|
"index/autocompleteCache.sqlite",
|
|
"out/config.js",
|
|
"types/core/index.d.ts",
|
|
];
|
|
|
|
for (const file of expectedFiles) {
|
|
const filePath = path.join(CONTINUE_GLOBAL_DIR, file);
|
|
expect(fs.existsSync(filePath)).toBe(true);
|
|
}
|
|
});
|
|
|
|
it("should properly edit config", async () => {
|
|
const config = await messenger.request(
|
|
"config/getBrowserSerialized",
|
|
undefined,
|
|
);
|
|
expect(config).toHaveProperty("models");
|
|
expect(config).toHaveProperty("embeddingsProvider");
|
|
expect(config).toHaveProperty("contextProviders");
|
|
expect(config).toHaveProperty("slashCommands");
|
|
});
|
|
});
|