From e7bb5a7bcb24a2773eaafe918cd44cf6043c417c Mon Sep 17 00:00:00 2001 From: Felix Angelov Date: Wed, 19 Jun 2024 15:29:30 -0500 Subject: [PATCH] chore: revert flaky `cache clear` integration test --- .github/workflows/e2e.yaml | 4 +- .../integration_test/helpers.dart | 24 ---------- .../shorebird_cli_cache_test.dart | 44 ------------------- .../shorebird_cli_integration_test.dart | 23 +++++++++- 4 files changed, 22 insertions(+), 73 deletions(-) delete mode 100644 packages/shorebird_cli/integration_test/helpers.dart delete mode 100644 packages/shorebird_cli/integration_test/shorebird_cli_cache_test.dart diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index c8153628..33158ac0 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -144,7 +144,5 @@ jobs: cache: true - name: 🧪 Run Integration Tests - # Run a single test at a time to ensure that one test does not interfere with another - # since some commands might change the state of the cli installation. - run: dart test integration_test -j 1 + run: dart test integration_test working-directory: packages/shorebird_cli diff --git a/packages/shorebird_cli/integration_test/helpers.dart b/packages/shorebird_cli/integration_test/helpers.dart deleted file mode 100644 index 04140220..00000000 --- a/packages/shorebird_cli/integration_test/helpers.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'dart:io'; - -import 'package:mason_logger/mason_logger.dart'; - -/// Helper function to run a command in the shell, meant to be used in tests. -/// -/// It will take a command string, like `shorebird --version`, run it in the -/// shell, and return the result. -ProcessResult runCommand( - String command, { - required String workingDirectory, - Logger? logger, -}) { - final parts = command.split(' '); - final executable = parts.first; - final arguments = parts.skip(1).toList(); - (logger ?? Logger()).info('running $command in $workingDirectory'); - return Process.runSync( - executable, - arguments, - runInShell: true, - workingDirectory: workingDirectory, - ); -} diff --git a/packages/shorebird_cli/integration_test/shorebird_cli_cache_test.dart b/packages/shorebird_cli/integration_test/shorebird_cli_cache_test.dart deleted file mode 100644 index 95a2c1ab..00000000 --- a/packages/shorebird_cli/integration_test/shorebird_cli_cache_test.dart +++ /dev/null @@ -1,44 +0,0 @@ -import 'package:mason_logger/mason_logger.dart'; -import 'package:scoped_deps/scoped_deps.dart'; -import 'package:shorebird_cli/src/auth/auth.dart'; -import 'package:shorebird_cli/src/http_client/http_client.dart'; -import 'package:shorebird_cli/src/logger.dart'; -import 'package:shorebird_cli/src/platform.dart'; -import 'package:shorebird_cli/src/shorebird_env.dart'; -import 'package:test/test.dart'; - -import 'helpers.dart'; - -R runWithOverrides(R Function() body) { - return runScoped( - body, - values: { - authRef, - httpClientRef, - loggerRef, - platformRef, - shorebirdEnvRef, - }, - ); -} - -void main() { - group('shorebird cache', () { - group('clear', () { - tearDown(() { - // Run an arbritery, fast command, so cache will be restored - // for the next test. - runCommand('--version', workingDirectory: '.'); - }); - - test('can clear the cache', () { - final result = runCommand( - 'shorebird cache clear', - workingDirectory: '.', - ); - - expect(result.exitCode, equals(ExitCode.success.code)); - }); - }); - }); -} diff --git a/packages/shorebird_cli/integration_test/shorebird_cli_integration_test.dart b/packages/shorebird_cli/integration_test/shorebird_cli_integration_test.dart index 2b70e7aa..ea6f226b 100644 --- a/packages/shorebird_cli/integration_test/shorebird_cli_integration_test.dart +++ b/packages/shorebird_cli/integration_test/shorebird_cli_integration_test.dart @@ -16,8 +16,6 @@ import 'package:shorebird_code_push_client/shorebird_code_push_client.dart'; import 'package:test/test.dart'; import 'package:uuid/uuid.dart'; -import 'helpers.dart'; - R runWithOverrides(R Function() body) { return runScoped( body, @@ -44,6 +42,27 @@ void main() { ), ); + /// Helper function to run a command in the shell, meant to be used in tests. + /// + /// It will take a command string, like `shorebird --version`, run it in the + /// shell, and return the result. + ProcessResult runCommand( + String command, { + required String workingDirectory, + Logger? logger, + }) { + final parts = command.split(' '); + final executable = parts.first; + final arguments = parts.skip(1).toList(); + (logger ?? Logger()).info('running $command in $workingDirectory'); + return Process.runSync( + executable, + arguments, + runInShell: true, + workingDirectory: workingDirectory, + ); + } + test('--version', () { final result = runCommand('shorebird --version', workingDirectory: '.'); expect(result.stderr, isEmpty);