diff --git a/packages/integration-tests/src/process-controller/execa_process_manager.ts b/packages/integration-tests/src/process-controller/execa_process_killer.ts similarity index 100% rename from packages/integration-tests/src/process-controller/execa_process_manager.ts rename to packages/integration-tests/src/process-controller/execa_process_killer.ts diff --git a/packages/integration-tests/src/process-controller/predicated_action.ts b/packages/integration-tests/src/process-controller/predicated_action.ts index 36fba75556..c63316970c 100644 --- a/packages/integration-tests/src/process-controller/predicated_action.ts +++ b/packages/integration-tests/src/process-controller/predicated_action.ts @@ -5,7 +5,7 @@ import { ExecaChildProcess } from 'execa'; */ export enum ActionType { SEND_INPUT_TO_PROCESS, - MAKE_CODE_CHANGES, + UPDATE_FILE_CONTENT, ASSERT_ON_PROCESS_OUTPUT, KILL_PROCESS, } @@ -18,8 +18,8 @@ type KillProcess = { actionType: ActionType.KILL_PROCESS; action: (execaProcess: ExecaChildProcess) => Promise; }; -type MakeCodeChangesAction = { - actionType: ActionType.MAKE_CODE_CHANGES; +type UpdateFileContentAction = { + actionType: ActionType.UPDATE_FILE_CONTENT; action: () => Promise; }; type AssertOnProcessOutputAction = { @@ -30,7 +30,7 @@ type AssertOnProcessOutputAction = { export type Action = | SendInputToProcessAction | KillProcess - | MakeCodeChangesAction + | UpdateFileContentAction | AssertOnProcessOutputAction; /** diff --git a/packages/integration-tests/src/process-controller/predicated_action_macros.ts b/packages/integration-tests/src/process-controller/predicated_action_macros.ts index 8a91686391..700bc79980 100644 --- a/packages/integration-tests/src/process-controller/predicated_action_macros.ts +++ b/packages/integration-tests/src/process-controller/predicated_action_macros.ts @@ -9,7 +9,7 @@ import { PredicatedActionBuilder } from './predicated_action_queue_builder.js'; /** * Reusable predicates: Wait for sandbox to finish and emit "✨ Total time: xx.xxs" */ -export const waitForSandboxDeployment = () => +export const waitForSandboxDeploymentToPrintTotalTime = () => new PredicatedActionBuilder().waitForLineIncludes('Total time'); /** @@ -44,8 +44,8 @@ export const rejectCleanupSandbox = () => * Reusable predicated action: Wait for sandbox to become idle and then update the * backend code which should trigger sandbox again */ -export const updateBackendCode = (from: URL, to: URL) => { - return waitForSandboxToBecomeIdle().updateBackendCode(from, to); +export const updateFileContent = (from: URL, to: URL) => { + return waitForSandboxToBecomeIdle().updateFileContent(from, to); }; /** @@ -58,5 +58,7 @@ export const interruptSandbox = () => waitForSandboxToBecomeIdle().sendCtrlC(); * than the threshold. */ export const ensureDeploymentTimeLessThan = (seconds: number) => { - return waitForSandboxDeployment().ensureDeploymentTimeLessThan(seconds); + return waitForSandboxDeploymentToPrintTotalTime().ensureDeploymentTimeLessThan( + seconds + ); }; diff --git a/packages/integration-tests/src/process-controller/predicated_action_queue_builder.ts b/packages/integration-tests/src/process-controller/predicated_action_queue_builder.ts index 80e58dcee8..c489136e47 100644 --- a/packages/integration-tests/src/process-controller/predicated_action_queue_builder.ts +++ b/packages/integration-tests/src/process-controller/predicated_action_queue_builder.ts @@ -6,7 +6,7 @@ import { import os from 'os'; import fs from 'fs/promises'; -import { killExecaProcess } from './execa_process_manager.js'; +import { killExecaProcess } from './execa_process_killer.js'; import { ExecaChildProcess } from 'execa'; export const CONTROL_C = '\x03'; @@ -68,9 +68,9 @@ export class PredicatedActionBuilder { * Update the last predicated action to update backend code by copying files from * `from` location to `to` location. */ - updateBackendCode = (from: URL, to: URL) => { + updateFileContent = (from: URL, to: URL) => { this.getLastPredicatedAction().then = { - actionType: ActionType.MAKE_CODE_CHANGES, + actionType: ActionType.UPDATE_FILE_CONTENT, action: async () => { await fs.cp(from, to, { recursive: true, diff --git a/packages/integration-tests/src/process-controller/process_controller.ts b/packages/integration-tests/src/process-controller/process_controller.ts index 06a197431a..e04b175b53 100644 --- a/packages/integration-tests/src/process-controller/process_controller.ts +++ b/packages/integration-tests/src/process-controller/process_controller.ts @@ -2,7 +2,7 @@ import { Options, execa } from 'execa'; import readline from 'readline'; import { PredicatedActionBuilder } from './predicated_action_queue_builder.js'; import { ActionType } from './predicated_action.js'; -import { killExecaProcess } from './execa_process_manager.js'; +import { killExecaProcess } from './execa_process_killer.js'; /** * Provides an abstractions for sending and receiving data on stdin/out of a child process * @@ -79,7 +79,7 @@ export class ProcessController { expectKilled = true; await currentInteraction.then.action(execaProcess); break; - case ActionType.MAKE_CODE_CHANGES: + case ActionType.UPDATE_FILE_CONTENT: await currentInteraction.then.action(); break; case ActionType.ASSERT_ON_PROCESS_OUTPUT: diff --git a/packages/integration-tests/src/test-e2e/deployment.test.ts b/packages/integration-tests/src/test-e2e/deployment.test.ts index a4af0ee89c..e13203e998 100644 --- a/packages/integration-tests/src/test-e2e/deployment.test.ts +++ b/packages/integration-tests/src/test-e2e/deployment.test.ts @@ -8,8 +8,8 @@ import { ensureDeploymentTimeLessThan, interruptSandbox, rejectCleanupSandbox, - updateBackendCode, - waitForSandboxDeployment, + updateFileContent, + waitForSandboxDeploymentToPrintTotalTime, } from '../process-controller/predicated_action_macros.js'; import { createEmptyAmplifyProject } from '../create_empty_amplify_project.js'; import { @@ -91,7 +91,7 @@ void describe('amplify deploys', () => { }); await amplifyCli(['sandbox'], testProjectRoot) - .do(waitForSandboxDeployment()) + .do(waitForSandboxDeploymentToPrintTotalTime()) .do(interruptSandbox()) .do(rejectCleanupSandbox()) .run(); @@ -109,7 +109,7 @@ void describe('amplify deploys', () => { const processController = amplifyCli( ['sandbox', '--dirToWatch', 'amplify'], testProjectRoot - ).do(waitForSandboxDeployment()); + ).do(waitForSandboxDeploymentToPrintTotalTime()); for (const update of testProject.updates) { const fileToUpdate = pathToFileURL( @@ -120,7 +120,7 @@ void describe('amplify deploys', () => { ); processController - .do(updateBackendCode(fileToUpdate, updateSource)) + .do(updateFileContent(fileToUpdate, updateSource)) .do( ensureDeploymentTimeLessThan(update.deploymentThresholdInSeconds) );