Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run integration tests connected to a chrome device #5917

Merged
merged 11 commits into from
Jun 20, 2023

Conversation

elliette
Copy link
Member

@elliette elliette commented Jun 13, 2023

Work towards #5703

Follow up to #5854

  • Adds support for running integration tests connected to a chrome device
  • Runs all supported tests connected to a chrome device during CI

The goal is to help catch regressions that are specific to web apps.

'debugger_panel_test.dart',
'app_test.dart',
// TODO(https://github.com/flutter/devtools/issues/5874): Enable once supported on web.
// 'eval_and_browse_test.dart',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elliette elliette changed the title Run integration tests connected to web device Run integration tests connected to a chrome device Jun 13, 2023
packages/devtools_app/integration_test/run_tests.dart Outdated Show resolved Hide resolved
packages/devtools_app/integration_test/run_tests.dart Outdated Show resolved Hide resolved
packages/devtools_app/integration_test/run_tests.dart Outdated Show resolved Hide resolved
Comment on lines 276 to 280
assert(
target != null,
'Please specify a test target (e.g. ${testTargetArg}path/to/test.dart',
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we allowing target to be null now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to parse the args to see if the testAppDevice arg is provided, but the parsing itself was asserting that the testTarget wasn't null. Therefore if we were trying to run all web tests (and therefore not specifying a test target), it would fail with the assertion error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what we want to do instead is leave this assertion here, and move the fix for this issue upstream to run_tests.dart

We can create the TestRunnerArgs from:

[
          ...testRunnerArgs,
          '${TestRunnerArgs.testTargetArg}$testTarget',
],

which is what we pass into the _runTest method in run_tests.dart. Instead of passing in a list of strings to that method, let's just pass in these args that you can parse at the top of the main method before you create the testAppDevice var. Then this assertion won't be hit, but we can still have the guarantee here that this code is not being called with a null test target

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not 100% sure the change I've made is what you asked for, but I added the assertion back and moved the check for whether the test supports the test app device from main to _runTest (so that we only do the check once we have a test target). LMK what you think!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a couple suggestions below that would need to be paired with this:

  if (testTargetProvided) {
    final args = TestRunnerArgs(testRunnerArgs);
    // TODO(kenz): add support for specifying a directory as the target instead
    // of a single file.
    await _runTest(args);
  } else {
    // Run all tests since a target test was not provided.
    final testDirectory = Directory(_testDirectory);
    final testFiles = testDirectory
        .listSync(recursive: true)
        .where((testFile) => testFile.path.endsWith(_testSuffix));
    for (final testFile in testFiles) {
      final testTarget = testFile.path;
      final args = TestRunnerArgs([
        ...testRunnerArgs,
        '${TestRunnerArgs.testTargetArg}$testTarget',
      ]);
      await _runTest(args);
    }
  }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice! I think I've applied all the suggestions

'flutter-tester';
testAppDevice = TestAppDevice.fromArgName(
argWithTestAppDevice?.substring(testAppDeviceArg.length) ??
'flutter-tester',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use TestAppDevice.flutterTester.argName instead of the 'flutter-tester' string

Copy link
Member

@kenzieschmoll kenzieschmoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one nit and lgtm

@elliette elliette added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 17, 2023
@auto-submit
Copy link

auto-submit bot commented Jun 17, 2023

auto label is removed for flutter/devtools, pr: 5917, due to - The status or check suite test_ddc has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jun 17, 2023
copybara-service bot pushed a commit to dart-lang/sdk that referenced this pull request Jun 20, 2023
Follow up to https://dart-review.googlesource.com/c/sdk/+/307970

Learned from Kenzie this was possible :) flutter/devtools#5917 (comment)

Bug: #52636
Change-Id: Ic244765a6258c000c4171ece35273609c7ee5929
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309831
Commit-Queue: Elliott Brooks <elliottbrooks@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
@elliette elliette merged commit d449ede into flutter:master Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants