Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Fix crawlComplete exception when running tests#12659

Merged
marcelgerber merged 1 commit intomasterfrom
marcel/crawl-complete-exception
Aug 14, 2016
Merged

Fix crawlComplete exception when running tests#12659
marcelgerber merged 1 commit intomasterfrom
marcel/crawl-complete-exception

Conversation

@marcelgerber
Copy link
Copy Markdown
Contributor

Fixes #12658. (cc @ficristo)

Turns out the fix is quite straightforward.

@ficristo
Copy link
Copy Markdown
Collaborator

ficristo commented Aug 9, 2016

The change itself LGTM, but I'm not sure if instead we should always have the project name at this point in the code.
Maybe @abose knows.

Comment thread src/search/FindInFiles.js Outdated

function nodeFileCacheComplete(event, numFiles, cacheSize) {
var projectName = ProjectManager.getProjectRoot().name || "noName00";
var projectName = ProjectManager.getProjectRoot();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Small nit / bikeshedding: instead of assigning the return value getProjectRoot() to projectName, it could be a bit cleaner if it was something like:

var projectRoot = ProjectManager.getProjectRoot();
var projectName = projectRoot ? projectRoot.name : null;

if (!projectName) {
  projectName = "noName00";
}

In general I think that there should never be an situation where projectRoot.name is empty anyways until Brackets supports opening up with no projects at all.

@petetnt
Copy link
Copy Markdown
Collaborator

petetnt commented Aug 9, 2016

I agree with @ficristo, there really shouldn't be any situation where there wasn't a projectRoot but the search was running, should there?

@marcelgerber marcelgerber force-pushed the marcel/crawl-complete-exception branch from d911ab3 to 4a5eb4a Compare August 9, 2016 20:04
@marcelgerber
Copy link
Copy Markdown
Contributor Author

To me, it looks like the Node instance sends the event both to the test window and the Jasmine window, where obviously, no project is loaded. So it runs fine in the test window, but throws this exception in the parent Test Runner window.

@ficristo
Copy link
Copy Markdown
Collaborator

@marcelgerber to me you are the expert so if you think is fine it's ok for me.
But would be nice, if possible, to add at least a log or something in the unexpected case:

if no project name then
  if not test window then
    log "unexpected"
  end
  projectname = NoName00
end

@marcelgerber
Copy link
Copy Markdown
Contributor Author

marcelgerber commented Aug 14, 2016

So, I just made sure my assumption is correct: Both the Test Runner and the test window receive an event in this case, and the Test Runner cannot handle it properly. I'm not sure whether it's the same event though (I think it is).

One way would be (assuming it is one event) for the Test Runner to ignore all Node events it is being sent, which is definitely the more general solution and may prevent other issues as well. On the other hand, I'm not sure if some Node events are expected for tests to pass.
Also, I'm not quite sure how to know whether the current window is the Test Runner or not.

I'll look into it.

@marcelgerber marcelgerber force-pushed the marcel/crawl-complete-exception branch from 4a5eb4a to 653ac8c Compare August 14, 2016 18:56
@marcelgerber
Copy link
Copy Markdown
Contributor Author

So, it turns out the SpecRunner definitely needs to receive Node events.
I updated the PR to have it ignore just this event.

Comment thread src/search/FindInFiles.js

function nodeFileCacheComplete(event, numFiles, cacheSize) {
var projectName = ProjectManager.getProjectRoot().name || "noName00";
if (/\/test\/SpecRunner\.html$/.test(window.location.pathname)) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would be nice to check for the /brackets/i regex too. But I don't know the location on the other OS.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We cannot be certain what the git clone is named on the system. Also, it's very likely that a Brackets Shell window that has a SpecRunner.html loaded, which in turn loaded the rest of Brackets, actually belongs to Brackets ;)

@ficristo
Copy link
Copy Markdown
Collaborator

I left a couple of comments, but otherwise LGTM.
@petetnt needs to check too.

@petetnt
Copy link
Copy Markdown
Collaborator

petetnt commented Aug 14, 2016

LGTM too 👍

@marcelgerber marcelgerber merged commit c395259 into master Aug 14, 2016
@marcelgerber marcelgerber deleted the marcel/crawl-complete-exception branch August 14, 2016 20:11
@ficristo ficristo added this to the Release 1.8 milestone Aug 15, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exception in 'crawlComplete' listener

3 participants