From 1f04e3f01619f488cd18f6ad76475fd2a0b1483b Mon Sep 17 00:00:00 2001 From: Bill Glesias Date: Thu, 18 May 2023 09:47:59 -0400 Subject: [PATCH] chore: change processing nomenclature to compressing when printing the run. --- cli/CHANGELOG.md | 1 + ..._FAILED.html => VIDEO_CAPTURE_FAILED.html} | 4 +- .../VIDEO_COMPRESSION_FAILED.html | 44 +++++++++++++++++++ packages/errors/src/errors.ts | 12 ++++- .../test/unit/visualSnapshotErrors_spec.ts | 9 +++- packages/graphql/schemas/schema.graphql | 3 +- packages/server/lib/modes/run.ts | 44 +++++++++++-------- packages/server/lib/util/print-run.ts | 8 ++-- packages/server/lib/video_capture.ts | 6 +-- .../expected_stdout_bundle_failures.txt | 4 +- .../server/expected_stdout_failures_outro.txt | 4 +- .../server/expected_stdout_passing.txt | 4 +- .../__snapshots__/browser_path_spec.js | 4 +- system-tests/__snapshots__/plugins_spec.js | 4 +- system-tests/__snapshots__/record_spec.js | 16 +++---- system-tests/__snapshots__/studio_spec.ts.js | 20 ++++----- .../__snapshots__/web_security_spec.js | 2 +- system-tests/lib/system-tests.ts | 8 ++-- 18 files changed, 133 insertions(+), 64 deletions(-) rename packages/errors/__snapshot-html__/{VIDEO_POST_PROCESSING_FAILED.html => VIDEO_CAPTURE_FAILED.html} (78%) create mode 100644 packages/errors/__snapshot-html__/VIDEO_COMPRESSION_FAILED.html diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index fc6441362e3f..80602a39eb19 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -13,6 +13,7 @@ _Released 05/23/2023 (PENDING)_ **Misc:** - Updated styling & content of Cypress Cloud slideshows when not logged in or no runs have been recorded. Addresses [#26181](https://github.com/cypress-io/cypress/issues/26181). +- Changed the nomenclature of 'processing' to 'compressing' when terminal video output is printed during a run. Addresses [#26657](https://github.com/cypress-io/cypress/issues/26657). ## 12.12.0 diff --git a/packages/errors/__snapshot-html__/VIDEO_POST_PROCESSING_FAILED.html b/packages/errors/__snapshot-html__/VIDEO_CAPTURE_FAILED.html similarity index 78% rename from packages/errors/__snapshot-html__/VIDEO_POST_PROCESSING_FAILED.html rename to packages/errors/__snapshot-html__/VIDEO_CAPTURE_FAILED.html index 5f0017b8e6fb..67c166a11714 100644 --- a/packages/errors/__snapshot-html__/VIDEO_POST_PROCESSING_FAILED.html +++ b/packages/errors/__snapshot-html__/VIDEO_CAPTURE_FAILED.html @@ -34,11 +34,11 @@ -
Warning: We failed processing this video.
+    
Warning: We failed capturing of this video.
 
 This error will not affect or change the exit code.
 
 Error: fail whale
     at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
-    at VIDEO_POST_PROCESSING_FAILED (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at VIDEO_CAPTURE_FAILED (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
 
\ No newline at end of file diff --git a/packages/errors/__snapshot-html__/VIDEO_COMPRESSION_FAILED.html b/packages/errors/__snapshot-html__/VIDEO_COMPRESSION_FAILED.html new file mode 100644 index 000000000000..343b4fa4c424 --- /dev/null +++ b/packages/errors/__snapshot-html__/VIDEO_COMPRESSION_FAILED.html @@ -0,0 +1,44 @@ + + + + + + + + + + + +
Warning: We failed compressing this video.
+
+This error will not affect or change the exit code.
+
+Error: fail whale
+    at makeErr (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+    at VIDEO_COMPRESSION_FAILED (cypress/packages/errors/test/unit/visualSnapshotErrors_spec.ts)
+
\ No newline at end of file diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts index 9bb15dce58db..e58a5fd753ce 100644 --- a/packages/errors/src/errors.ts +++ b/packages/errors/src/errors.ts @@ -75,9 +75,17 @@ export const AllCypressErrors = { ${fmt.stackTrace(arg1)}` }, - VIDEO_POST_PROCESSING_FAILED: (arg1: Error) => { + VIDEO_CAPTURE_FAILED: (arg1: Error) => { return errTemplate`\ - Warning: We failed processing this video. + Warning: We failed capturing of this video. + + This error will not affect or change the exit code. + + ${fmt.stackTrace(arg1)}` + }, + VIDEO_COMPRESSION_FAILED: (arg1: Error) => { + return errTemplate`\ + Warning: We failed compressing this video. This error will not affect or change the exit code. diff --git a/packages/errors/test/unit/visualSnapshotErrors_spec.ts b/packages/errors/test/unit/visualSnapshotErrors_spec.ts index 829f2ee8cb58..daaea744b39a 100644 --- a/packages/errors/test/unit/visualSnapshotErrors_spec.ts +++ b/packages/errors/test/unit/visualSnapshotErrors_spec.ts @@ -325,7 +325,14 @@ describe('visual error templates', () => { default: [err], } }, - VIDEO_POST_PROCESSING_FAILED: () => { + VIDEO_CAPTURE_FAILED: () => { + const err = makeErr() + + return { + default: [err], + } + }, + VIDEO_COMPRESSION_FAILED: () => { const err = makeErr() return { diff --git a/packages/graphql/schemas/schema.graphql b/packages/graphql/schemas/schema.graphql index cabc2e68865c..fddc1ab227dd 100644 --- a/packages/graphql/schemas/schema.graphql +++ b/packages/graphql/schemas/schema.graphql @@ -1236,7 +1236,8 @@ enum ErrorTypeEnum { UNEXPECTED_INTERNAL_ERROR UNEXPECTED_MUTATION_ERROR UNSUPPORTED_BROWSER_VERSION - VIDEO_POST_PROCESSING_FAILED + VIDEO_CAPTURE_FAILED + VIDEO_COMPRESSION_FAILED VIDEO_RECORDING_FAILED } diff --git a/packages/server/lib/modes/run.ts b/packages/server/lib/modes/run.ts index c61cae11592f..60ee0ccf49f4 100644 --- a/packages/server/lib/modes/run.ts +++ b/packages/server/lib/modes/run.ts @@ -310,20 +310,28 @@ async function startVideoRecording (options: { previous?: VideoRecording, projec return videoRecording } -const warnVideoRecordingFailed = (err) => { - // log that post processing was attempted +const warnVideoCaptureFailed = (err) => { + // log that capturing video was attempted // but failed and don't let this change the run exit code - errors.warning('VIDEO_POST_PROCESSING_FAILED', err) + errors.warning('VIDEO_CAPTURE_FAILED', err) } -async function postProcessRecording (options: { quiet: boolean, videoCompression: number | boolean, shouldUploadVideo: boolean, processOptions: Omit }) { +const warnVideoCompressionFailed = (err) => { + // log that compression was attempted + // but failed and don't let this change the run exit code + errors.warning('VIDEO_COMPRESSION_FAILED', err) +} + +async function compressRecording (options: { quiet: boolean, videoCompression: number | boolean, shouldUploadVideo: boolean, processOptions: Omit }) { debug('ending the video recording %o', options) // once this ended promises resolves - // then begin processing the file - // don't process anything if videoCompress is off + // then begin compressing the file + // don't compress anything if videoCompress is off // or we've been told not to upload the video if (options.videoCompression === false || options.videoCompression === 0 || options.shouldUploadVideo === false) { + debug('skipping compression') + return } @@ -332,17 +340,17 @@ async function postProcessRecording (options: { quiet: boolean, videoCompression videoCompression: Number(options.videoCompression), } - function continueProcessing (onProgress?: (progress: number) => void) { - return videoCapture.process({ ...processOptions, onProgress }) + function continueWithCompression (onProgress?: (progress: number) => void) { + return videoCapture.compress({ ...processOptions, onProgress }) } if (options.quiet) { - return continueProcessing() + return continueWithCompression() } - const { onProgress } = printResults.displayVideoProcessingProgress(processOptions) + const { onProgress } = printResults.displayVideoCompressionProgress(processOptions) - return continueProcessing(onProgress) + return continueWithCompression(onProgress) } function launchBrowser (options: { browser: Browser, spec: SpecWithRelativeRoot, setScreenshotMetadata: SetScreenshotMetadata, screenshots: ScreenshotMetadata[], projectRoot: string, shouldLaunchNewTab: boolean, onError: (err: Error) => void, videoRecording?: VideoRecording }) { @@ -610,7 +618,7 @@ async function waitForTestsToFinishRunning (options: { project: Project, screens debug('ended video capture') } catch (err) { videoCaptureFailed = true - warnVideoRecordingFailed(err) + warnVideoCaptureFailed(err) } telemetry.getSpan('video:capture')?.setAttributes({ videoCaptureFailed })?.end() @@ -628,7 +636,7 @@ async function waitForTestsToFinishRunning (options: { project: Project, screens if (!videoExists) { // the video file no longer exists at the path where we expect it, // possibly because the user deleted it in the after:spec event - debug(`No video found after spec ran - skipping processing. Video path: ${videoName}`) + debug(`No video found after spec ran - skipping compression. Video path: ${videoName}`) results.video = null } @@ -641,7 +649,7 @@ async function waitForTestsToFinishRunning (options: { project: Project, screens results.shouldUploadVideo = shouldUploadVideo if (!shouldUploadVideo) { - debug(`Spec run had no failures and config.videoUploadOnPasses=false. Skip processing video. Video path: ${videoName}`) + debug(`Spec run had no failures and config.videoUploadOnPasses=false. Skip compressing video. Video path: ${videoName}`) results.video = null } @@ -668,11 +676,11 @@ async function waitForTestsToFinishRunning (options: { project: Project, screens } if (videoExists && !skippedSpec && !videoCaptureFailed) { - const span = telemetry.startSpan({ name: 'video:post:processing' }) + const span = telemetry.startSpan({ name: 'video:compression' }) const chaptersConfig = videoCapture.generateFfmpegChaptersConfig(results.tests) try { - debug('post processing recording') + debug('compressing recording') span?.setAttributes({ videoName, @@ -680,7 +688,7 @@ async function waitForTestsToFinishRunning (options: { project: Project, screens compressedVideoName: videoRecording.api.compressedVideoName, }) - await postProcessRecording({ + await compressRecording({ shouldUploadVideo, quiet, videoCompression, @@ -693,7 +701,7 @@ async function waitForTestsToFinishRunning (options: { project: Project, screens }) } catch (err) { videoCaptureFailed = true - warnVideoRecordingFailed(err) + warnVideoCompressionFailed(err) } span?.end() } diff --git a/packages/server/lib/util/print-run.ts b/packages/server/lib/util/print-run.ts index 138669000b4c..961735ed05da 100644 --- a/packages/server/lib/util/print-run.ts +++ b/packages/server/lib/util/print-run.ts @@ -474,7 +474,7 @@ function displayScreenshots (screenshots: Screenshot[] = []) { console.log('') } -export function displayVideoProcessingProgress (opts: { videoName: string, videoCompression: number | false }) { +export function displayVideoCompressionProgress (opts: { videoName: string, videoCompression: number | false }) { console.log('') terminal.header('Video', { @@ -498,7 +498,7 @@ export function displayVideoProcessingProgress (opts: { videoName: string, video table.push([ gray('-'), - gray('Started processing:'), + gray('Started compressing:'), chalk.cyan(`Compressing to ${opts.videoCompression} CRF`), ]) @@ -515,7 +515,7 @@ export function displayVideoProcessingProgress (opts: { videoName: string, video const dur = `${humanTime.long(finished)}` const table = terminal.table({ - colWidths: [3, 21, 61, 15], + colWidths: [3, 22, 60, 15], colAligns: ['left', 'left', 'left', 'right'], type: 'noBorder', style: { @@ -529,7 +529,7 @@ export function displayVideoProcessingProgress (opts: { videoName: string, video table.push([ gray('-'), - gray('Finished processing:'), + gray('Finished compressing:'), gray(dur), ]) diff --git a/packages/server/lib/video_capture.ts b/packages/server/lib/video_capture.ts index c673da2d237e..8375e0f5cb4d 100644 --- a/packages/server/lib/video_capture.ts +++ b/packages/server/lib/video_capture.ts @@ -113,7 +113,7 @@ export type StartOptions = { videoName: string // If set, expect input frames as webm chunks. webmInput?: boolean - // Callback for asynchronous errors in video processing/compression. + // Callback for asynchronous errors in video capturing/compression. onError?: (err: Error, stdout: string, stderr: string) => void } @@ -279,14 +279,14 @@ export function start (options: StartOptions) { }) } -export async function process (options: ProcessOptions) { +export async function compress (options: ProcessOptions) { let total = null const metaFileName = `${options.videoName}.meta` const addChaptersMeta = options.chaptersConfig && await fs.writeFile(metaFileName, options.chaptersConfig).then(() => true) return new Promise((resolve, reject) => { - debug('processing video %o', options) + debug('compressing video %o', options) const command = ffmpeg({ priority: 20, diff --git a/packages/server/test/support/fixtures/server/expected_stdout_bundle_failures.txt b/packages/server/test/support/fixtures/server/expected_stdout_bundle_failures.txt index d66756fc7048..f3ecaa014a56 100644 --- a/packages/server/test/support/fixtures/server/expected_stdout_bundle_failures.txt +++ b/packages/server/test/support/fixtures/server/expected_stdout_bundle_failures.txt @@ -35,8 +35,8 @@ Fix the error in your code and re-run your tests. (Video) - - Started processing: Compressing to 32 CRF - - Finished processing: /foo/bar/.projects/e2e/cypress/videos/abc123.mp4 (X seconds) + - Started compressing: Compressing to 32 CRF + - Finished compressing: /foo/bar/.projects/e2e/cypress/videos/abc123.mp4 (X seconds) (Run Finished) diff --git a/packages/server/test/support/fixtures/server/expected_stdout_failures_outro.txt b/packages/server/test/support/fixtures/server/expected_stdout_failures_outro.txt index bdd0b698ffd7..7ea41c3af206 100644 --- a/packages/server/test/support/fixtures/server/expected_stdout_failures_outro.txt +++ b/packages/server/test/support/fixtures/server/expected_stdout_failures_outro.txt @@ -19,8 +19,8 @@ (Video) - - Started processing: Compressing to 32 CRF - - Finished processing: /foo/bar/.projects/e2e/cypress/videos/abc123.mp4 (X seconds) + - Started compressing: Compressing to 32 CRF + - Finished compressing: /foo/bar/.projects/e2e/cypress/videos/abc123.mp4 (X seconds) (Run Finished) \ No newline at end of file diff --git a/packages/server/test/support/fixtures/server/expected_stdout_passing.txt b/packages/server/test/support/fixtures/server/expected_stdout_passing.txt index c654e0a93729..1e766df36df9 100644 --- a/packages/server/test/support/fixtures/server/expected_stdout_passing.txt +++ b/packages/server/test/support/fixtures/server/expected_stdout_passing.txt @@ -35,8 +35,8 @@ (Video) - - Started processing: Compressing to 32 CRF - - Finished processing: /foo/bar/.projects/e2e/cypress/videos/abc123.mp4 (X seconds) + - Started compressing: Compressing to 32 CRF + - Finished compressing: /foo/bar/.projects/e2e/cypress/videos/abc123.mp4 (X seconds) (Run Finished) \ No newline at end of file diff --git a/system-tests/__snapshots__/browser_path_spec.js b/system-tests/__snapshots__/browser_path_spec.js index 5a23804b70ca..90b5285e782d 100644 --- a/system-tests/__snapshots__/browser_path_spec.js +++ b/system-tests/__snapshots__/browser_path_spec.js @@ -39,8 +39,8 @@ exports['e2e launching browsers by path works with an installed browser path 1'] (Video) - - Started processing: Compressing to 32 CRF - - Finished processing: /XXX/XXX/XXX/cypress/videos/simple.cy.js.mp4 (X second) + - Started compressing: Compressing to 32 CRF + - Finished compressing: /XXX/XXX/XXX/cypress/videos/simple.cy.js.mp4 (X second) ==================================================================================================== diff --git a/system-tests/__snapshots__/plugins_spec.js b/system-tests/__snapshots__/plugins_spec.js index 0c336deefddf..37d180ce20c2 100644 --- a/system-tests/__snapshots__/plugins_spec.js +++ b/system-tests/__snapshots__/plugins_spec.js @@ -167,8 +167,8 @@ exports['e2e plugins can modify config from plugins 1'] = ` (Video) - - Started processing: Compressing to 20 CRF - - Finished processing: X second(s) + - Started compressing: Compressing to 20 CRF + - Finished compressing: X second(s) - Video output: /XXX/XXX/XXX/cypress/videos/app.cy.js.mp4 diff --git a/system-tests/__snapshots__/record_spec.js b/system-tests/__snapshots__/record_spec.js index 84f4020878a7..b8af5699d8b9 100644 --- a/system-tests/__snapshots__/record_spec.js +++ b/system-tests/__snapshots__/record_spec.js @@ -67,8 +67,8 @@ Fix the error in your code and re-run your tests. (Video) - - Started processing: Compressing to 32 CRF - - Finished processing: X second(s) + - Started compressing: Compressing to 32 CRF + - Finished compressing: X second(s) - Video output: /XXX/XXX/XXX/cypress/videos/record_error.cy.js.mp4 @@ -124,8 +124,8 @@ Because this error occurred during a \`before each\` hook we are skipping the re (Video) - - Started processing: Compressing to 32 CRF - - Finished processing: X second(s) + - Started compressing: Compressing to 32 CRF + - Finished compressing: X second(s) - Video output: /XXX/XXX/XXX/cypress/videos/record_fail.cy.js.mp4 @@ -226,8 +226,8 @@ We dynamically generated a new test to display this failure. (Video) - - Started processing: Compressing to 32 CRF - - Finished processing: X second(s) + - Started compressing: Compressing to 32 CRF + - Finished compressing: X second(s) - Video output: /XXX/XXX/XXX/cypress/videos/record_uncaught.cy.js.mp4 @@ -2357,8 +2357,8 @@ Because this error occurred during a \`before each\` hook we are skipping the re (Video) - - Started processing: Compressing to 32 CRF - - Finished processing: X second(s) + - Started compressing: Compressing to 32 CRF + - Finished compressing: X second(s) - Video output: /XXX/XXX/XXX/cypress/videos/record_fail.cy.js.mp4 diff --git a/system-tests/__snapshots__/studio_spec.ts.js b/system-tests/__snapshots__/studio_spec.ts.js index 28df3801e7a3..081efb21051b 100644 --- a/system-tests/__snapshots__/studio_spec.ts.js +++ b/system-tests/__snapshots__/studio_spec.ts.js @@ -45,8 +45,8 @@ exports['e2e studio / extends test'] = ` (Video) - - Started processing: Compressing to 32 CRF - - Finished processing: /XXX/XXX/XXX/cypress/videos/extend.spec.js.mp4 (X second) + - Started compressing: Compressing to 32 CRF + - Finished compressing: /XXX/XXX/XXX/cypress/videos/extend.spec.js.mp4 (X second) ==================================================================================================== @@ -227,8 +227,8 @@ exports['e2e studio / creates new test'] = ` (Video) - - Started processing: Compressing to 32 CRF - - Finished processing: /XXX/XXX/XXX/cypress/videos/new.spec.js.mp4 (X second) + - Started compressing: Compressing to 32 CRF + - Finished compressing: /XXX/XXX/XXX/cypress/videos/new.spec.js.mp4 (X second) ==================================================================================================== @@ -339,8 +339,8 @@ exports['e2e studio / can write to imported files'] = ` (Video) - - Started processing: Compressing to 32 CRF - - Finished processing: /XXX/XXX/XXX/cypress/videos/external.spec.js.mp4 (X second) + - Started compressing: Compressing to 32 CRF + - Finished compressing: /XXX/XXX/XXX/cypress/videos/external.spec.js.mp4 (X second) ==================================================================================================== @@ -445,8 +445,8 @@ exports['e2e studio / extends test without source maps'] = ` (Video) - - Started processing: Compressing to 32 CRF - - Finished processing: /XXX/XXX/XXX/cypress/videos/extend.spec.js.mp4 (X second) + - Started compressing: Compressing to 32 CRF + - Finished compressing: /XXX/XXX/XXX/cypress/videos/extend.spec.js.mp4 (X second) ==================================================================================================== @@ -542,8 +542,8 @@ exports['e2e studio / creates new test without source maps'] = ` (Video) - - Started processing: Compressing to 32 CRF - - Finished processing: /XXX/XXX/XXX/cypress/videos/new.spec.js.mp4 (X second) + - Started compressing: Compressing to 32 CRF + - Finished compressing: /XXX/XXX/XXX/cypress/videos/new.spec.js.mp4 (X second) ==================================================================================================== diff --git a/system-tests/__snapshots__/web_security_spec.js b/system-tests/__snapshots__/web_security_spec.js index 1cb47d92de60..2c92ea8e03a0 100644 --- a/system-tests/__snapshots__/web_security_spec.js +++ b/system-tests/__snapshots__/web_security_spec.js @@ -195,7 +195,7 @@ This option will not have an effect in Firefox. Tests that rely on web security 1 passing -Warning: We failed processing this video. +Warning: We failed capturing of this video. This error will not affect or change the exit code. diff --git a/system-tests/lib/system-tests.ts b/system-tests/lib/system-tests.ts index cac0dc7b1cb3..3d6f6dff6936 100644 --- a/system-tests/lib/system-tests.ts +++ b/system-tests/lib/system-tests.ts @@ -307,14 +307,14 @@ Bluebird.config({ // extract the 'Difference' section from a snap-shot-it error message const diffRe = /Difference\n-{10}\n([\s\S]*)\n-{19}\nSaved snapshot text/m const expectedAddedVideoSnapshotLines = [ - 'Warning: We failed processing this video.', + 'Warning: We failed capturing of this video.', 'This error will not affect or change the exit code.', 'TimeoutError: operation timed out', '[stack trace lines]', ] const expectedDeletedVideoSnapshotLines = [ '(Video)', - '- Started processing: Compressing to 32 CRF', + '- Started compressing: Compressing to 32 CRF', ] const sometimesAddedSpacingLine = '' const sometimesAddedVideoSnapshotLine = '│ Video: false │' @@ -332,7 +332,7 @@ const isVideoSnapshotError = (err: Error) => { for (const line of lines) { // past this point, the content is variable - mp4 path length - if (line.includes('Finished processing:')) break + if (line.includes('Finished compressing:')) break if (line.charAt(0) === '+') added.push(line.slice(1).trim()) @@ -895,7 +895,7 @@ const systemTests = { throw err } - console.log('(system tests warning) Firefox failed to process the video, but this is being ignored due to known issues with video processing in Firefox.') + console.log('(system tests warning) Firefox failed to process the video, but this is being ignored due to known issues with video capturing in Firefox.') } }