Skip to content

Refactor API #713

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 8 commits into from
Apr 7, 2016
Merged

Refactor API #713

merged 8 commits into from
Apr 7, 2016

Conversation

jamestalmage
Copy link
Contributor

This is preliminary work on simplifying the API. The major (breaking) change is a new test-run event that passes an emitter for that specific test run. Said emitter is an instance of the new TestData class (might be more appropriately named TestRun). This contains test results that we were storing directly on the API instance. That really doesn't make sense anymore given that the API instance is called multiple times by Watcher. I feel this way makes a little more sense. There is definitely room for further refactoring, but this represents a big diff, and I want to get it reviewed and merged before further refactoring.

@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @sotojuan, @naptowncode and @ariporad to be potential reviewers

this.hasExclusive = true;
this.testCount = 0;
}
testData.listenToTestRun(emitter);
Copy link
Member

Choose a reason for hiding this comment

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

observeFork?

@novemberborn
Copy link
Member

This contains test results that we were storing directly on the API instance. That really doesn't make sense anymore given that the API instance is called multiple times by Watcher. I feel this way makes a little more sense.

Yea that's always stuck me as strange.

Note though that the reporters reference these properties. Their tests use a stubbed api so they're still passing.

@novemberborn
Copy link
Member

Said emitter is an instance of the new TestData class (might be more appropriately named TestRun).

RunStatus?

@jamestalmage
Copy link
Contributor Author

I set reporter.api to the new testData instance with each test-run event.

I added a to-do comment that that should be cleaned up. I might just change it to pass testData as a param to reporter events. Some reporters could be stateless that way.

@novemberborn
Copy link
Member

I might just change it to pass testData as a param to reporter events. Some reporters could be stateless that way.

👍

@jamestalmage jamestalmage force-pushed the simplify-api branch 3 times, most recently from 62cd74e to 112fa8a Compare April 6, 2016 03:12
@@ -431,7 +447,8 @@ group('chokidar is installed', function (beforeEach, test, group) {
t.plan(2);

files = ['foo-{bar,baz}.js'];
api.excludePatterns = ['!*bar*'];
// TODO(@jamestalmage, @novemberborn): There is no way for users to actually set exclude patterns yet.
avaFiles.defaultExcludePatterns.returns(['!*bar*']);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@novemberborn - Currently, there is no way for users to set the exclude patterns. Is this a feature that needs to be exposed?

You access api.excludePatterns in watcher, but that's a static value that never changes (I guess an API consumer could, but we haven't published that, so ...).

Should we open an issue about this, or is avaFiles.defaultExcludePatterns() all you need.

Copy link
Member

Choose a reason for hiding this comment

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

@jamestalmage you could add exclude patterns to files. We should just make sure to still use the default include patterns if files only contains negated patterns. That's how the watcher behaves with source patterns.

Copy link
Member

Choose a reason for hiding this comment

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

@jamestalmage jamestalmage merged commit 31b268e into avajs:master Apr 7, 2016
@jamestalmage jamestalmage deleted the simplify-api branch April 7, 2016 06:01
var EventEmitter = require('events').EventEmitter;
var formatter = require('./enhance-assert').formatter();

function TestData(opts) {
Copy link
Member

Choose a reason for hiding this comment

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

@jamestalmage did you mean to rename this to RunStatus?

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 did indeed

novemberborn added a commit that referenced this pull request Apr 13, 2016
Since #713 the API no longer emits 'dependencies' events. These are emitted
instead by the RunStatus, which can be obtained by listening to the 'test-run'
event on the API.

The watcher tests use a mocked API object which wasn't updated to reflect these
changes. Consequently dependency tracking was broken since #713 was merged.

This commit fixes the watcher and the corresponding tests. I've also added an
integration test which does not rely on mocking, helping us detect breakage
sooner.
jamestalmage pushed a commit that referenced this pull request Apr 13, 2016
Since #713 the API no longer emits 'dependencies' events. These are emitted
instead by the RunStatus, which can be obtained by listening to the 'test-run'
event on the API.

The watcher tests use a mocked API object which wasn't updated to reflect these
changes. Consequently dependency tracking was broken since #713 was merged.

This commit fixes the watcher and the corresponding tests. I've also added an
integration test which does not rely on mocking, helping us detect breakage
sooner.
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.

3 participants