refactor(coding-agent): reorganized test files to proper test directory structure

- Moved test files from src/core to test/core directory.
- Moved test files from src/core/tools to test/tools directory.
- Moved test files from src/discovery to test/discovery directory.
- Updated import paths to reflect new test file locations.
This commit is contained in:
can1357
2026-01-19 00:07:23 +01:00
parent ffe79ab5b9
commit 92ec2550d2
47 changed files with 121 additions and 112 deletions
@@ -1,6 +1,6 @@
import { describe, expect, it } from "bun:test";
import { executePythonWithKernel, type PythonKernelExecutor } from "./python-executor";
import type { KernelDisplayOutput, KernelExecuteOptions, KernelExecuteResult } from "./python-kernel";
import { executePythonWithKernel, type PythonKernelExecutor } from "../../src/core/python-executor";
import type { KernelDisplayOutput, KernelExecuteOptions, KernelExecuteResult } from "../../src/core/python-kernel";
class FakeKernel implements PythonKernelExecutor {
private result: KernelExecuteResult;
@@ -1,7 +1,7 @@
import { afterEach, describe, expect, it, vi } from "bun:test";
import { disposeAllKernelSessions, executePython } from "./python-executor";
import type { KernelExecuteResult } from "./python-kernel";
import * as pythonKernel from "./python-kernel";
import { disposeAllKernelSessions, executePython } from "../../src/core/python-executor";
import type { KernelExecuteResult } from "../../src/core/python-kernel";
import * as pythonKernel from "../../src/core/python-kernel";
class FakeKernel {
execute = vi.fn(async () => this.result);
@@ -1,6 +1,6 @@
import { describe, expect, it } from "bun:test";
import { executePythonWithKernel, type PythonKernelExecutor } from "./python-executor";
import type { KernelExecuteOptions, KernelExecuteResult } from "./python-kernel";
import { executePythonWithKernel, type PythonKernelExecutor } from "../../src/core/python-executor";
import type { KernelExecuteOptions, KernelExecuteResult } from "../../src/core/python-kernel";
class FakeKernel implements PythonKernelExecutor {
constructor(
@@ -1,7 +1,7 @@
import { describe, expect, it } from "bun:test";
import { executePython } from "./python-executor";
import type { KernelExecuteOptions, KernelExecuteResult } from "./python-kernel";
import { PythonKernel } from "./python-kernel";
import { executePython } from "../../src/core/python-executor";
import type { KernelExecuteOptions, KernelExecuteResult } from "../../src/core/python-kernel";
import { PythonKernel } from "../../src/core/python-kernel";
interface KernelStub {
execute: (code: string, options?: KernelExecuteOptions) => Promise<KernelExecuteResult>;
@@ -1,6 +1,6 @@
import { afterEach, describe, expect, it, vi } from "bun:test";
import { disposeAllKernelSessions, executePython } from "./python-executor";
import * as pythonKernel from "./python-kernel";
import { disposeAllKernelSessions, executePython } from "../../src/core/python-executor";
import * as pythonKernel from "../../src/core/python-kernel";
class FakeKernel {
executeCalls = 0;
@@ -1,8 +1,8 @@
import { afterEach, describe, expect, it } from "bun:test";
import { rmSync } from "node:fs";
import { executePythonWithKernel, type PythonKernelExecutor } from "./python-executor";
import type { KernelExecuteOptions, KernelExecuteResult } from "./python-kernel";
import { DEFAULT_MAX_BYTES } from "./tools/truncate";
import { executePythonWithKernel, type PythonKernelExecutor } from "../../src/core/python-executor";
import type { KernelExecuteOptions, KernelExecuteResult } from "../../src/core/python-kernel";
import { DEFAULT_MAX_BYTES } from "../../src/core/tools/truncate";
class FakeKernel implements PythonKernelExecutor {
private result: KernelExecuteResult;
@@ -1,6 +1,6 @@
import { describe, expect, it } from "bun:test";
import { executePythonWithKernel, type PythonKernelExecutor } from "./python-executor";
import type { KernelExecuteOptions, KernelExecuteResult } from "./python-kernel";
import { executePythonWithKernel, type PythonKernelExecutor } from "../../src/core/python-executor";
import type { KernelExecuteOptions, KernelExecuteResult } from "../../src/core/python-kernel";
class FakeKernel implements PythonKernelExecutor {
private result: KernelExecuteResult;
@@ -1,6 +1,6 @@
import { afterEach, describe, expect, it } from "bun:test";
import { disposeAllKernelSessions, executePython } from "./python-executor";
import { type KernelExecuteOptions, type KernelExecuteResult, PythonKernel } from "./python-kernel";
import { disposeAllKernelSessions, executePython } from "../../src/core/python-executor";
import { type KernelExecuteOptions, type KernelExecuteResult, PythonKernel } from "../../src/core/python-kernel";
process.env.OMP_PYTHON_SKIP_CHECK = "1";
@@ -1,6 +1,6 @@
import { describe, expect, it } from "bun:test";
import { executePythonWithKernel, type PythonKernelExecutor } from "./python-executor";
import type { KernelExecuteOptions, KernelExecuteResult } from "./python-kernel";
import { executePythonWithKernel, type PythonKernelExecutor } from "../../src/core/python-executor";
import type { KernelExecuteOptions, KernelExecuteResult } from "../../src/core/python-kernel";
class FakeKernel implements PythonKernelExecutor {
private result: KernelExecuteResult;
@@ -7,9 +7,14 @@ import {
type PythonKernelExecutor,
resetPreludeDocsCache,
warmPythonEnvironment,
} from "./python-executor";
import { type KernelExecuteOptions, type KernelExecuteResult, type PreludeHelper, PythonKernel } from "./python-kernel";
import { DEFAULT_MAX_BYTES } from "./tools/truncate";
} from "../../src/core/python-executor";
import {
type KernelExecuteOptions,
type KernelExecuteResult,
type PreludeHelper,
PythonKernel,
} from "../../src/core/python-kernel";
import { DEFAULT_MAX_BYTES } from "../../src/core/tools/truncate";
class FakeKernel implements PythonKernelExecutor {
private result: KernelExecuteResult;
@@ -1,5 +1,5 @@
import { describe, expect, it } from "bun:test";
import { type KernelDisplayOutput, PythonKernel } from "./python-kernel";
import { type KernelDisplayOutput, PythonKernel } from "../../src/core/python-kernel";
const renderDisplay = (
PythonKernel as unknown as {
@@ -1,8 +1,8 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "bun:test";
import * as shell from "../utils/shell";
import * as shellSnapshot from "../utils/shell-snapshot";
import { PythonKernel } from "./python-kernel";
import { PYTHON_PRELUDE } from "./python-prelude";
import { PythonKernel } from "../../src/core/python-kernel";
import { PYTHON_PRELUDE } from "../../src/core/python-prelude";
import * as shell from "../../src/utils/shell";
import * as shellSnapshot from "../../src/utils/shell-snapshot";
class FakeWebSocket {
static OPEN = 1;
@@ -1,7 +1,7 @@
import { afterEach, beforeEach, describe, expect, it } from "bun:test";
import { disposeAllKernelSessions, executePython } from "./python-executor";
import type { KernelExecuteOptions, KernelExecuteResult } from "./python-kernel";
import { PythonKernel } from "./python-kernel";
import { disposeAllKernelSessions, executePython } from "../../src/core/python-executor";
import type { KernelExecuteOptions, KernelExecuteResult } from "../../src/core/python-kernel";
import { PythonKernel } from "../../src/core/python-kernel";
class FakeKernel {
executeCalls = 0;
@@ -1,5 +1,9 @@
import { describe, expect, it } from "bun:test";
import { deserializeWebSocketMessage, type JupyterMessage, serializeWebSocketMessage } from "./python-kernel";
import {
deserializeWebSocketMessage,
type JupyterMessage,
serializeWebSocketMessage,
} from "../../src/core/python-kernel";
const encoder = new TextEncoder();
@@ -3,7 +3,7 @@ import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import type { Subprocess } from "bun";
import { PythonKernel } from "./python-kernel";
import { PythonKernel } from "../../src/core/python-kernel";
type SpawnOptions = Parameters<typeof Bun.spawn>[1];
@@ -1,6 +1,6 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "bun:test";
import { type KernelDisplayOutput, PythonKernel } from "./python-kernel";
import { PYTHON_PRELUDE } from "./python-prelude";
import { type KernelDisplayOutput, PythonKernel } from "../../src/core/python-kernel";
import { PYTHON_PRELUDE } from "../../src/core/python-prelude";
type JupyterMessage = {
channel: string;
@@ -2,7 +2,7 @@ import { afterEach, describe, expect, it } from "bun:test";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { basename, join, resolve } from "node:path";
import { discoverPythonModules, loadPythonModules, type PythonModuleExecutor } from "./python-modules";
import { discoverPythonModules, loadPythonModules, type PythonModuleExecutor } from "../../src/core/python-modules";
const fixturesDir = resolve(__dirname, "../../test/fixtures/python-modules");
@@ -1,8 +1,8 @@
import { describe, expect, it } from "bun:test";
import { existsSync } from "node:fs";
import { join } from "node:path";
import { resetPreludeDocsCache, warmPythonEnvironment } from "./python-executor";
import { createPythonTool, getPythonToolDescription } from "./tools/python";
import { resetPreludeDocsCache, warmPythonEnvironment } from "../../src/core/python-executor";
import { createPythonTool, getPythonToolDescription } from "../../src/core/tools/python";
const resolvePythonPath = (): string | null => {
const venvPath = process.env.VIRTUAL_ENV;
@@ -1,5 +1,5 @@
import { describe, expect, it } from "bun:test";
import { SettingsManager } from "./settings-manager";
import { SettingsManager } from "../../src/core/settings-manager";
describe("SettingsManager python settings", () => {
it("defaults to both and session", () => {
@@ -1,5 +1,5 @@
import { describe, expect, it } from "bun:test";
import { createOutputSink } from "./streaming-output";
import { createOutputSink } from "../../src/core/streaming-output";
function makeLargeOutput(size: number): string {
return "x".repeat(size);
@@ -1,5 +1,5 @@
import { describe, expect, it } from "bun:test";
import { buildSystemPrompt } from "./system-prompt";
import { buildSystemPrompt } from "../../src/core/system-prompt";
describe("buildSystemPrompt", () => {
it("includes python tool details when enabled", async () => {
@@ -1,5 +1,5 @@
import { describe, expect, test } from "bun:test";
import { parseFrontmatter } from "../core/frontmatter";
import { parseFrontmatter } from "../../src/core/frontmatter";
describe("parseFrontmatter", () => {
const parse = (content: string) => parseFrontmatter(content, { source: "tests:frontmatter", level: "off" });
@@ -1,5 +1,5 @@
import { describe, expect, it } from "bun:test";
import { BUILTIN_TOOLS, createTools, HIDDEN_TOOLS, type ToolSession } from "./index";
import { BUILTIN_TOOLS, createTools, HIDDEN_TOOLS, type ToolSession } from "../../src/core/tools/index";
process.env.OMP_PYTHON_SKIP_CHECK = "1";
@@ -2,9 +2,9 @@ import { describe, expect, it, vi } from "bun:test";
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import * as pythonExecutor from "../python-executor";
import type { ToolSession } from "./index";
import { createPythonTool } from "./python";
import * as pythonExecutor from "../../src/core/python-executor";
import type { ToolSession } from "../../src/core/tools/index";
import { createPythonTool } from "../../src/core/tools/python";
function createSession(cwd: string): ToolSession {
return {
@@ -1,7 +1,7 @@
import { describe, expect, it, vi } from "bun:test";
import * as pythonKernelModule from "../python-kernel";
import type { ToolSession } from "./index";
import { createTools } from "./index";
import * as pythonKernelModule from "../../src/core/python-kernel";
import type { ToolSession } from "../../src/core/tools/index";
import { createTools } from "../../src/core/tools/index";
function createTestSession(overrides: Partial<ToolSession> = {}): ToolSession {
return {
@@ -1,8 +1,8 @@
import { describe, expect, it } from "bun:test";
import stripAnsi from "strip-ansi";
import { getThemeByName } from "../../modes/interactive/theme/theme";
import { pythonToolRenderer } from "./python";
import { truncateTail } from "./truncate";
import { pythonToolRenderer } from "../../src/core/tools/python";
import { truncateTail } from "../../src/core/tools/truncate";
import { getThemeByName } from "../../src/modes/interactive/theme/theme";
describe("pythonToolRenderer", () => {
it("renders truncated output when collapsed and full output when expanded", () => {
@@ -1,5 +1,5 @@
import { describe, expect, it } from "bun:test";
import { createTools, type ToolSession } from "./index";
import { createTools, type ToolSession } from "../../src/core/tools/index";
function createSession(overrides: Partial<ToolSession> = {}): ToolSession {
return {
@@ -1,7 +1,7 @@
import { afterAll, beforeAll, describe, expect, it, vi } from "bun:test";
import * as pythonExecutor from "../python-executor";
import { createTools, type ToolSession } from "./index";
import { createPythonTool } from "./python";
import * as pythonExecutor from "../../src/core/python-executor";
import { createTools, type ToolSession } from "../../src/core/tools/index";
import { createPythonTool } from "../../src/core/tools/python";
let previousSkipCheck: string | undefined;
@@ -1,6 +1,6 @@
import { describe, expect, it } from "bun:test";
import { sanitizeSchemaForGoogle } from "@oh-my-pi/pi-ai";
import { BUILTIN_TOOLS, createTools, HIDDEN_TOOLS, type ToolSession } from "./index";
import { BUILTIN_TOOLS, createTools, HIDDEN_TOOLS, type ToolSession } from "../../src/core/tools/index";
/**
* Problematic JSON Schema features that cause issues with various providers.
@@ -1,8 +1,8 @@
import { describe, expect, it } from "bun:test";
import { handleArxiv } from "./arxiv";
import { handleIacr } from "./iacr";
import { handlePubMed } from "./pubmed";
import { handleSemanticScholar } from "./semantic-scholar";
import { handleArxiv } from "../../../src/core/tools/web-scrapers/arxiv";
import { handleIacr } from "../../../src/core/tools/web-scrapers/iacr";
import { handlePubMed } from "../../../src/core/tools/web-scrapers/pubmed";
import { handleSemanticScholar } from "../../../src/core/tools/web-scrapers/semantic-scholar";
const SKIP = !process.env.WEB_FETCH_INTEGRATION;
@@ -1,6 +1,6 @@
import { describe, expect, it } from "bun:test";
import { handleOpenCorporates } from "./opencorporates";
import { handleSecEdgar } from "./sec-edgar";
import { handleOpenCorporates } from "../../../src/core/tools/web-scrapers/opencorporates";
import { handleSecEdgar } from "../../../src/core/tools/web-scrapers/sec-edgar";
const SKIP = !process.env.WEB_FETCH_INTEGRATION;
@@ -1,8 +1,8 @@
import { describe, expect, it } from "bun:test";
import { handleDevTo } from "./devto";
import { handleGitLab } from "./gitlab";
import { handleHackerNews } from "./hackernews";
import { handleLobsters } from "./lobsters";
import { handleDevTo } from "../../../src/core/tools/web-scrapers/devto";
import { handleGitLab } from "../../../src/core/tools/web-scrapers/gitlab";
import { handleHackerNews } from "../../../src/core/tools/web-scrapers/hackernews";
import { handleLobsters } from "../../../src/core/tools/web-scrapers/lobsters";
const SKIP = !process.env.WEB_FETCH_INTEGRATION;
@@ -1,6 +1,6 @@
import { describe, expect, it } from "bun:test";
import { handleMDN } from "./mdn";
import { handleReadTheDocs } from "./readthedocs";
import { handleMDN } from "../../../src/core/tools/web-scrapers/mdn";
import { handleReadTheDocs } from "../../../src/core/tools/web-scrapers/readthedocs";
const SKIP = !process.env.WEB_FETCH_INTEGRATION;
@@ -1,7 +1,7 @@
import { describe, expect, it } from "bun:test";
import { handleArtifactHub } from "./artifacthub";
import { handleCoinGecko } from "./coingecko";
import { handleDiscogs } from "./discogs";
import { handleArtifactHub } from "../../../src/core/tools/web-scrapers/artifacthub";
import { handleCoinGecko } from "../../../src/core/tools/web-scrapers/coingecko";
import { handleDiscogs } from "../../../src/core/tools/web-scrapers/discogs";
const SKIP = !process.env.WEB_FETCH_INTEGRATION;
@@ -1,6 +1,6 @@
import { describe, expect, it } from "bun:test";
import { handleGitHub } from "./github";
import { handleGitHubGist } from "./github-gist";
import { handleGitHub } from "../../../src/core/tools/web-scrapers/github";
import { handleGitHubGist } from "../../../src/core/tools/web-scrapers/github-gist";
const SKIP = !process.env.WEB_FETCH_INTEGRATION;
@@ -1,7 +1,7 @@
import { describe, expect, it } from "bun:test";
import { handleHuggingFace } from "./huggingface";
import { handleSpotify } from "./spotify";
import { handleVimeo } from "./vimeo";
import { handleHuggingFace } from "../../../src/core/tools/web-scrapers/huggingface";
import { handleSpotify } from "../../../src/core/tools/web-scrapers/spotify";
import { handleVimeo } from "../../../src/core/tools/web-scrapers/vimeo";
const SKIP = !process.env.WEB_FETCH_INTEGRATION;
@@ -1,10 +1,10 @@
import { describe, expect, it } from "bun:test";
import { handleChocolatey } from "./chocolatey";
import { handleDockerHub } from "./dockerhub";
import { handleHackage } from "./hackage";
import { handleMetaCPAN } from "./metacpan";
import { handleRepology } from "./repology";
import { handleTerraform } from "./terraform";
import { handleChocolatey } from "../../../src/core/tools/web-scrapers/chocolatey";
import { handleDockerHub } from "../../../src/core/tools/web-scrapers/dockerhub";
import { handleHackage } from "../../../src/core/tools/web-scrapers/hackage";
import { handleMetaCPAN } from "../../../src/core/tools/web-scrapers/metacpan";
import { handleRepology } from "../../../src/core/tools/web-scrapers/repology";
import { handleTerraform } from "../../../src/core/tools/web-scrapers/terraform";
const SKIP = !process.env.WEB_FETCH_INTEGRATION;
@@ -1,10 +1,10 @@
import { describe, expect, it } from "bun:test";
import { handleAur } from "./aur";
import { handleBrew } from "./brew";
import { handleMaven } from "./maven";
import { handleNuGet } from "./nuget";
import { handlePackagist } from "./packagist";
import { handleRubyGems } from "./rubygems";
import { handleAur } from "../../../src/core/tools/web-scrapers/aur";
import { handleBrew } from "../../../src/core/tools/web-scrapers/brew";
import { handleMaven } from "../../../src/core/tools/web-scrapers/maven";
import { handleNuGet } from "../../../src/core/tools/web-scrapers/nuget";
import { handlePackagist } from "../../../src/core/tools/web-scrapers/packagist";
import { handleRubyGems } from "../../../src/core/tools/web-scrapers/rubygems";
const SKIP = !process.env.WEB_FETCH_INTEGRATION;
@@ -1,10 +1,10 @@
import { describe, expect, it } from "bun:test";
import { handleCratesIo } from "./crates-io";
import { handleGoPkg } from "./go-pkg";
import { handleHex } from "./hex";
import { handleNpm } from "./npm";
import { handlePubDev } from "./pub-dev";
import { handlePyPI } from "./pypi";
import { handleCratesIo } from "../../../src/core/tools/web-scrapers/crates-io";
import { handleGoPkg } from "../../../src/core/tools/web-scrapers/go-pkg";
import { handleHex } from "../../../src/core/tools/web-scrapers/hex";
import { handleNpm } from "../../../src/core/tools/web-scrapers/npm";
import { handlePubDev } from "../../../src/core/tools/web-scrapers/pub-dev";
import { handlePyPI } from "../../../src/core/tools/web-scrapers/pypi";
const SKIP = !process.env.WEB_FETCH_INTEGRATION;
@@ -1,7 +1,7 @@
import { describe, expect, it } from "bun:test";
import { handleBiorxiv } from "./biorxiv";
import { handleOpenLibrary } from "./openlibrary";
import { handleWikidata } from "./wikidata";
import { handleBiorxiv } from "../../../src/core/tools/web-scrapers/biorxiv";
import { handleOpenLibrary } from "../../../src/core/tools/web-scrapers/openlibrary";
import { handleWikidata } from "../../../src/core/tools/web-scrapers/wikidata";
const SKIP = !process.env.WEB_FETCH_INTEGRATION;
@@ -1,6 +1,6 @@
import { describe, expect, it } from "bun:test";
import { handleNvd } from "./nvd";
import { handleOsv } from "./osv";
import { handleNvd } from "../../../src/core/tools/web-scrapers/nvd";
import { handleOsv } from "../../../src/core/tools/web-scrapers/osv";
const SKIP = !process.env.WEB_FETCH_INTEGRATION;
@@ -1,6 +1,6 @@
import { describe, expect, it } from "bun:test";
import { handleBluesky } from "./bluesky";
import { handleMastodon } from "./mastodon";
import { handleBluesky } from "../../../src/core/tools/web-scrapers/bluesky";
import { handleMastodon } from "../../../src/core/tools/web-scrapers/mastodon";
const SKIP = !process.env.WEB_FETCH_INTEGRATION;
@@ -1,7 +1,7 @@
import { describe, expect, it } from "bun:test";
import { handleReddit } from "./reddit";
import { handleStackOverflow } from "./stackoverflow";
import { handleTwitter } from "./twitter";
import { handleReddit } from "../../../src/core/tools/web-scrapers/reddit";
import { handleStackOverflow } from "../../../src/core/tools/web-scrapers/stackoverflow";
import { handleTwitter } from "../../../src/core/tools/web-scrapers/twitter";
const SKIP = !process.env.WEB_FETCH_INTEGRATION;
@@ -1,5 +1,5 @@
import { describe, expect, it } from "bun:test";
import { handleStackOverflow } from "./stackoverflow";
import { handleStackOverflow } from "../../../src/core/tools/web-scrapers/stackoverflow";
const SKIP = !process.env.WEB_FETCH_INTEGRATION;
@@ -1,7 +1,7 @@
import { describe, expect, it } from "bun:test";
import { handleCheatSh } from "./cheatsh";
import { handleRfc } from "./rfc";
import { handleTldr } from "./tldr";
import { handleCheatSh } from "../../../src/core/tools/web-scrapers/cheatsh";
import { handleRfc } from "../../../src/core/tools/web-scrapers/rfc";
import { handleTldr } from "../../../src/core/tools/web-scrapers/tldr";
const SKIP = !process.env.WEB_FETCH_INTEGRATION;
@@ -1,5 +1,5 @@
import { describe, expect, it } from "bun:test";
import { handleWikipedia } from "./wikipedia";
import { handleWikipedia } from "../../../src/core/tools/web-scrapers/wikipedia";
const SKIP = !process.env.WEB_FETCH_INTEGRATION;
@@ -1,5 +1,5 @@
import { describe, expect, it } from "bun:test";
import { handleYouTube } from "./youtube";
import { handleYouTube } from "../../../src/core/tools/web-scrapers/youtube";
const SKIP = !process.env.WEB_FETCH_INTEGRATION;