Skip to content

CP-1129 Add flag to automatically start pub serve when running tests/coverage #92

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

Merged
merged 1 commit into from
Nov 23, 2015

Conversation

greglittlefield-wf
Copy link
Contributor

Ultimate Problem

Tests and coverage currently cannot be run with files served from a Pub server.

See #79.

Solution

  • Add PubServeTask
    • Allows creation and management of pub serve instances.
  • Add pub-serve CLI option and pubServe config option to test/coverage tasks.
    • Automatically spins up a Pub server that is used to run the tests.
  • Add integration tests for dart_dev coverage/dart_dev test in projects that require a Pub server.

Other changes

Tweak Reporter.logGroup code to be more flexible, and indent for multiline Stream events.

Testing

  • Verify that integration tests for test/coverage tasks pass.
  • Verify that a real consumer package can run dart_dev test/dart_dev coverage using a pub server.
  • Verify that pub serve output is well-formatted.

FYA: @evanweible-wf @trentgrover-wf
FYI: @jacehensley-wf @aaronlademann-wf

if (pubServe) {
// Start `pub serve` on the `test` directory
pubServeTask = serve.pubServe(additionalArgs: ['test']);
var serveInfo = await pubServeTask.serveInfos.first;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd like to log some output here... At the very least, an indication that the pub server is starting, but ideally the pub serve output up until it starts.

Should pubServeTask be a field on TestTask, so that it can be accessed and logged accordingly in test/cli.dart?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah at this point, that's probably what I would do. You could break it up into two different parts - the logs up until the server is ready, and the remainder. That way you could print the first part immediately and the rest of it when the server is stopped.

@evanweible-wf
Copy link
Contributor

@greglittlefield-wf I think your approach here is fine. As you've seen, the current dart_dev architecture makes this feel a bit hacky, and it's definitely something I want to improve in 2.0.0. But for now, this seems to me like it should work

@greglittlefield-wf
Copy link
Contributor Author

Cool, I'll proceed with this approach and work toward finalizing it. Thanks for the feedback!

@codecov-io
Copy link

Current coverage is 45.12%

Merging #92 into master will decrease coverage by -2.93% as of 16761fa

Powered by Codecov. Updated on successful CI builds.

@greglittlefield-wf greglittlefield-wf changed the title Add flag to automatically start pub serve when running tests Add flag to automatically start pub serve when running tests/coverage Nov 19, 2015
@greglittlefield-wf
Copy link
Contributor Author

This is ready for final review. Any clue as to why tests are timing out on Travis? They seem to run fine locally.

}).timeout(const Duration(seconds: 10), onTimeout: () {
throw new TimeoutException(
'failed to detect `pub serve` directory containing ${htmlFile.path}');
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, now that I think about it, if we're passing in additionalArgs: ['test'] to startPubServe, this stream will almost assuredly contain only one event.

This should probably be changed to:

PubServeInfo serveInfo = await pubServeTask.serveInfos.first;
if (!path.isWithin(serveInfo.directory, htmlFile.path)) {
  throw '`pub serve` directory `${serveInfo.directory}` does not contain test file `${htmlFile.path}`.';
}

@evanweible-wf
Copy link
Contributor

Travis CI failure is an issue with Dart 1.13, I'm looking into it

if (line.contains(_testsPassedPattern)) {
break;

// Run the test in content-shell.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The diff for this section is easier to look at if you ignore whitespace changes.

@evanweible-wf
Copy link
Contributor

This should fix the CI failure once merged: #98

@trentgrover-wf
Copy link
Contributor

+1

@rmconsole3-wf
Copy link
Contributor

@greglittlefield-wf This pull request has merge conflicts, please resolve.

@greglittlefield-wf
Copy link
Contributor Author

Merge conflicts have been resolved, and it looks like the build is passing now. Thanks, @evanweible-wf!

@evanweible-wf
Copy link
Contributor

@greglittlefield-wf This looks great! Could you add this config option to the readme?

@greglittlefield-wf
Copy link
Contributor Author

@evanweible-wf Yup! Added in 851ae16.

@evanweible-wf
Copy link
Contributor

+1

@trentgrover-wf @maxwellpeterson-wf @dustinlessard-wf any of you care to take a look as well?

After that, last step would be a rebase and a squash into a single commit @greglittlefield-wf

@greglittlefield-wf
Copy link
Contributor Author

@evanweible-wf Rebased and squashed.

@maxwellpeterson-wf
Copy link
Member

+1

1 similar comment
@evanweible-wf
Copy link
Contributor

+1

@dustinlessard-wf
Copy link

+1 cool

@trentgrover-wf
Copy link
Contributor

+1
@jayudey-wf ready for merge

@jayudey-wf
Copy link
Contributor

do you think we need to add an update to the readme about ensuring that you have this in your pubspec.yaml if you want to serve your tests?

- test/pub_serve:
    $include: test/**_test{.*,}.dart

@jayudey-wf jayudey-wf changed the title Add flag to automatically start pub serve when running tests/coverage CP-1129 Add flag to automatically start pub serve when running tests/coverage Nov 23, 2015
@greglittlefield-wf
Copy link
Contributor Author

@jayudey-wf That's a good idea, I'll add that.

@greglittlefield-wf greglittlefield-wf force-pushed the pub_serve branch 2 times, most recently from 0cbcb2e to 1855b61 Compare November 23, 2015 15:41
@greglittlefield-wf
Copy link
Contributor Author

K, added info to README about setting up test to work with transformers in greglittlefield-wf@1855b61. Needs a +1.

@evanweible-wf Should I squash that commit in as well?

@evanweible-wf
Copy link
Contributor

@greglittlefield-wf sure, might as well. Readme changes look good

@greglittlefield-wf
Copy link
Contributor Author

Squashed and pushed.

@maxwellpeterson-wf
Copy link
Member

+1

@evanweible-wf
Copy link
Contributor

+1 @jayudey-wf ready for merge.

@jayudey-wf
Copy link
Contributor

QA Resource Approval: +10

  • Testing instruction
  • Dev +1's
  • Dev/QA +10 with detail of what was tested
    • verified that tests were passing, installed into two separate projects and made sure that test and coverage were still working as expected w/ and w/o the pub server going, pub serve logging looked ok
  • Unit test created/updated
  • All unit tests pass

Merging into master.

jayudey-wf added a commit that referenced this pull request Nov 23, 2015
CP-1129 Add flag to automatically start `pub serve` when running tests/coverage
@jayudey-wf jayudey-wf merged commit 5d2b6cc into Workiva:master Nov 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants