mirror of
https://github.com/browseros-ai/BrowserOS.git
synced 2026-05-14 08:03:58 +00:00
Compare commits
4 Commits
fix/browse
...
fix/tests-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
643f08ceac | ||
|
|
7755da5489 | ||
|
|
72e4d312e9 | ||
|
|
01603229a1 |
6
.github/workflows/test.yml
vendored
6
.github/workflows/test.yml
vendored
@@ -63,15 +63,15 @@ jobs:
|
||||
junit_path: test-results/server-root.xml
|
||||
needs_browser: false
|
||||
- suite: agent
|
||||
command: bun run test:agent
|
||||
command: (cd apps/agent && bun run test)
|
||||
junit_path: test-results/agent.xml
|
||||
needs_browser: false
|
||||
- suite: eval
|
||||
command: bun run test:eval
|
||||
command: (cd apps/eval && bun run test)
|
||||
junit_path: test-results/eval.xml
|
||||
needs_browser: false
|
||||
- suite: build
|
||||
command: bun run test:build
|
||||
command: bun run ./scripts/run-bun-test.ts ./scripts/build
|
||||
junit_path: test-results/build.xml
|
||||
needs_browser: false
|
||||
|
||||
|
||||
@@ -156,9 +156,14 @@ bun run build:server # Build production server resource artifacts and u
|
||||
bun run build:agent # Build agent extension
|
||||
|
||||
# Test
|
||||
bun run test # Run standard tests
|
||||
bun run test:cdp # Run CDP-based tests
|
||||
bun run test:integration # Run integration tests
|
||||
bun run test # Run all tests
|
||||
bun run test:all # Run all tests
|
||||
bun run test:main # Run key server tools and integration tests
|
||||
|
||||
# App-specific test groups (from packages/browseros-agent)
|
||||
cd apps/server && bun run test:tools
|
||||
cd apps/server && bun run test:cdp
|
||||
cd apps/server && bun run test:integration
|
||||
|
||||
# Quality
|
||||
bun run lint # Check with Biome
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"build": "bun run codegen && wxt build",
|
||||
"build:dev": "bun --env-file=.env.development wxt build --mode development",
|
||||
"zip": "wxt zip",
|
||||
"test": "bun run ../../scripts/run-bun-test.ts ./apps/agent",
|
||||
"compile": "bun --env-file=.env.development wxt prepare && tsgo --noEmit",
|
||||
"lint": "bunx biome check",
|
||||
"typecheck": "bun --env-file=.env.development wxt prepare && tsgo --noEmit",
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"eval": "bun --env-file=.env.development run src/index.ts",
|
||||
"test": "bun run ../../scripts/run-bun-test.ts ./apps/eval/tests",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -28,14 +28,8 @@
|
||||
"build:agent": "bun run codegen:agent && bun run --filter @browseros/agent build",
|
||||
"codegen:agent": "bun run --filter @browseros/agent codegen",
|
||||
"test": "bun run test:all",
|
||||
"test:all": "bun run test:server && bun run test:agent && bun run test:eval && bun run test:build",
|
||||
"test:server": "bun run --filter @browseros/server test",
|
||||
"test:tools": "bun run --filter @browseros/server test:tools",
|
||||
"test:cdp": "bun run --filter @browseros/server test:cdp",
|
||||
"test:integration": "bun run --filter @browseros/server test:integration",
|
||||
"test:agent": "bun run ./scripts/run-bun-test.ts ./apps/agent",
|
||||
"test:eval": "bun run ./scripts/run-bun-test.ts ./apps/eval/tests",
|
||||
"test:build": "bun run ./scripts/run-bun-test.ts ./scripts/build",
|
||||
"test:all": "bun run ./scripts/run-test-suite.ts all",
|
||||
"test:main": "bun run ./scripts/run-test-suite.ts main",
|
||||
"typecheck": "bun run --filter '*' typecheck",
|
||||
"lint": "bunx biome check",
|
||||
"lint:fix": "bunx biome check --write --unsafe",
|
||||
|
||||
110
packages/browseros-agent/scripts/run-test-suite.ts
Normal file
110
packages/browseros-agent/scripts/run-test-suite.ts
Normal file
@@ -0,0 +1,110 @@
|
||||
import { spawnSync } from 'node:child_process'
|
||||
import { resolve } from 'node:path'
|
||||
|
||||
type TestCommand = {
|
||||
label: string
|
||||
cwd?: string
|
||||
argv: readonly [string, ...string[]]
|
||||
}
|
||||
|
||||
const projectRoot = resolve(import.meta.dir, '..')
|
||||
const bun = process.execPath
|
||||
|
||||
const testSuites = {
|
||||
all: [
|
||||
{
|
||||
label: 'server tests',
|
||||
cwd: resolve(projectRoot, 'apps/server'),
|
||||
argv: [bun, 'run', 'test'],
|
||||
},
|
||||
{
|
||||
label: 'agent tests',
|
||||
cwd: resolve(projectRoot, 'apps/agent'),
|
||||
argv: [bun, 'run', 'test'],
|
||||
},
|
||||
{
|
||||
label: 'eval tests',
|
||||
cwd: resolve(projectRoot, 'apps/eval'),
|
||||
argv: [bun, 'run', 'test'],
|
||||
},
|
||||
{
|
||||
label: 'build script tests',
|
||||
argv: [bun, 'run', './scripts/run-bun-test.ts', './scripts/build'],
|
||||
},
|
||||
],
|
||||
main: [
|
||||
{
|
||||
label: 'server tools tests',
|
||||
cwd: resolve(projectRoot, 'apps/server'),
|
||||
argv: [bun, 'run', 'test:tools'],
|
||||
},
|
||||
{
|
||||
label: 'server integration tests',
|
||||
cwd: resolve(projectRoot, 'apps/server'),
|
||||
argv: [bun, 'run', 'test:integration'],
|
||||
},
|
||||
],
|
||||
} satisfies Record<string, readonly TestCommand[]>
|
||||
|
||||
type TestSuiteName = keyof typeof testSuites
|
||||
|
||||
function isTestSuiteName(value: string): value is TestSuiteName {
|
||||
return value in testSuites
|
||||
}
|
||||
|
||||
/** Prevents multi-step suites from overwriting a single shared JUnit report path. */
|
||||
function buildCommandEnv(): NodeJS.ProcessEnv {
|
||||
const env = { ...process.env }
|
||||
delete env.BROWSEROS_JUNIT_PATH
|
||||
return env
|
||||
}
|
||||
|
||||
function runCommand(command: TestCommand): number {
|
||||
console.log(`\n==> ${command.label}`)
|
||||
const result = spawnSync(command.argv[0], command.argv.slice(1), {
|
||||
cwd: command.cwd ?? projectRoot,
|
||||
env: buildCommandEnv(),
|
||||
stdio: 'inherit',
|
||||
})
|
||||
if (result.error) {
|
||||
throw result.error
|
||||
}
|
||||
if (result.signal) {
|
||||
console.error(
|
||||
`Command terminated by signal ${result.signal}: ${command.label}`,
|
||||
)
|
||||
return 1
|
||||
}
|
||||
const status = result.status ?? 1
|
||||
if (status !== 0) {
|
||||
console.error(`Command failed with exit code ${status}: ${command.label}`)
|
||||
}
|
||||
return status
|
||||
}
|
||||
|
||||
/** Runs a named test suite without shell chaining so each step reports its own status. */
|
||||
function runSuite(suiteName: TestSuiteName): number {
|
||||
let exitCode = 0
|
||||
for (const command of testSuites[suiteName]) {
|
||||
const status = runCommand(command)
|
||||
if (status !== 0 && exitCode === 0) {
|
||||
exitCode = status
|
||||
}
|
||||
}
|
||||
return exitCode
|
||||
}
|
||||
|
||||
function printUsage(): void {
|
||||
console.error(
|
||||
`Usage: bun run ./scripts/run-test-suite.ts <${Object.keys(testSuites).join('|')}>`,
|
||||
)
|
||||
}
|
||||
|
||||
if (import.meta.main) {
|
||||
const requestedSuite = process.argv[2]
|
||||
if (!requestedSuite || !isTestSuiteName(requestedSuite)) {
|
||||
printUsage()
|
||||
process.exit(1)
|
||||
}
|
||||
process.exit(runSuite(requestedSuite))
|
||||
}
|
||||
Reference in New Issue
Block a user