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

Fix crawlComplete exception when running tests #12659

Merged
merged 1 commit into from
Aug 14, 2016

Conversation

marcelgerber
Copy link
Contributor

Fixes #12658. (cc @ficristo)

Turns out the fix is quite straightforward.

@ficristo
Copy link
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.

@@ -96,7 +96,12 @@ define(function (require, exports, module) {
}

function nodeFileCacheComplete(event, numFiles, cacheSize) {
var projectName = ProjectManager.getProjectRoot().name || "noName00";
var projectName = ProjectManager.getProjectRoot();
Copy link
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
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
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
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
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
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.

@@ -93,7 +93,19 @@ define(function (require, exports, module) {
}

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

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

@petetnt
Copy link
Collaborator

petetnt commented Aug 14, 2016

LGTM too 👍

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