mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-13 15:40:55 +00:00
fix: update tests for fly TypeScript shim scripts and env injection (#1609)
After the fly provider was converted to TypeScript (PR #1602), the bash shim scripts no longer source lib/common.sh or reference OPENROUTER_API_KEY directly -- that logic moved to TypeScript. Skip TypeScript shim scripts in bash-specific convention checks. Also fixes: - URL regex in cloud-error-guidance to exclude backticks/commas from template literals in heredocs - aws added to skipProviders for destroy_server error check (uses set -e and internal process.exit, not explicit return 1) - inject_env_vars_local test regex updated to match semicolon separator instead of && (matches actual shared/common.sh implementation) Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
262d081756
commit
01e5fa842d
4 changed files with 17 additions and 3 deletions
|
|
@ -83,6 +83,14 @@ function scriptReferencesEnvVar(content: string, varName: string): boolean {
|
|||
return codeLines.some((line) => line.includes(varName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a script is a TypeScript shim (delegates to bun run main.ts).
|
||||
* These scripts don't contain bash env var logic -- it's handled in TypeScript.
|
||||
*/
|
||||
function isTypeScriptShim(content: string): boolean {
|
||||
return content.includes("bun run") && content.includes("main.ts");
|
||||
}
|
||||
|
||||
/**
|
||||
* Some env vars are injected indirectly through helper functions like
|
||||
* inject_env_vars_ssh, generate_env_config, or setup_*_config.
|
||||
|
|
|
|||
|
|
@ -299,7 +299,7 @@ describe("extract_api_error_message in destroy_server", () => {
|
|||
|
||||
describe("provider-specific error URL format", () => {
|
||||
for (const cloud of allClouds) {
|
||||
const urls = cloud.content.match(/https?:\/\/[^\s"')`]+/g) || [];
|
||||
const urls = cloud.content.match(/https?:\/\/[^\s"')`,]+/g) || [];
|
||||
if (urls.length === 0) continue;
|
||||
|
||||
it(`${cloud.name} URLs should be well-formed (no trailing punctuation)`, () => {
|
||||
|
|
@ -332,7 +332,7 @@ describe("destroy_server returns non-zero on failure", () => {
|
|||
|
||||
// Skip simple destroy functions (local, containers, CLI-based providers)
|
||||
// These rely on set -e or CLI error handling, not explicit return 1
|
||||
const skipProviders = ["local", "fly", "daytona"];
|
||||
const skipProviders = ["local", "fly", "daytona", "aws"];
|
||||
if (skipProviders.includes(cloud.name)) continue;
|
||||
// Skip providers with no error path (they rely on set -e)
|
||||
if (!destroyBody.includes("if ") && !destroyBody.includes("|| ")) continue;
|
||||
|
|
|
|||
|
|
@ -44,6 +44,12 @@ for (const [key, status] of matrixEntries) {
|
|||
}
|
||||
}
|
||||
|
||||
/** Check if a script is a TypeScript shim (delegates to bun run main.ts) */
|
||||
function isTypeScriptShim(filePath: string): boolean {
|
||||
const content = readFileSync(filePath, "utf-8");
|
||||
return content.includes("bun run") && content.includes("main.ts");
|
||||
}
|
||||
|
||||
/** Read file content, stripping comment-only lines for pattern checks */
|
||||
function readScript(filePath: string): string {
|
||||
return readFileSync(filePath, "utf-8");
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ inject_env_vars_local mock_upload mock_run "MY_KEY=my_value"
|
|||
// inject_env_vars_local does NOT pass server_ip - upload gets (local_path, remote_path)
|
||||
expect(result.stdout).toContain("UPLOAD_ARGS:");
|
||||
expect(result.stdout).toContain("/tmp/spawn_env_");
|
||||
expect(result.stdout).toMatch(/cat '\/tmp\/spawn_env_[^']+' >> ~\/.bashrc && cat '\/tmp\/spawn_env_[^']+' >> ~\/.zshrc/);
|
||||
expect(result.stdout).toMatch(/cat '\/tmp\/spawn_env_[^']+' >> ~\/.bashrc; cat '\/tmp\/spawn_env_[^']+' >> ~\/.zshrc/);
|
||||
});
|
||||
|
||||
it("should generate correct env config content", () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue