-
Notifications
You must be signed in to change notification settings - Fork 96
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
enable traces (sub/child-errors) and custom "error types" #418
Conversation
require('xregexp').forEach(this.output, regex, matchFunction.bind(this.currentMatch)); | ||
|
||
// first run all functional matches | ||
this.functions && this.functions.forEach((f, functionIndex) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this.functions
is set in the set
function I feel we can safely assume this will always be an array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
javascript scares me xD I add checks everywhere. But yea, I'll remove this check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, no it's not always set, only if functionMatch
is a value.
This amount of code almost warrants moving all linter related code to a |
I removed the criticality, and am parsing the type now. I added a few possible type values. Matches with unknown type are turned into |
|
nevermind, I found it :) works now specs are very weird with their error reporting. Most non-assertion errors just disappear into the void |
Shaping up nicely! I'll give this a test and a final review later today! |
} | ||
this.regex = { | ||
Error: this._prepareRegex(target.errorMatch), | ||
Warning: this._prepareRegex(target.warningMatch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why the keys here are capitalized?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
atom-build currently prints Error
capitalized, I'm generating that name from the field name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allright, makes sense!
Functionalitywise this is great, but I think we need some more documentation around this, with examples on how to add trace etc. The image you have in this PR would also be nice to spark interest! |
this.regex[kind] && this.regex[kind].forEach((regex, i) => { | ||
regex && require('xregexp').forEach(this.output, regex, (match, matchIndex) => { | ||
match.id = 'error-match-' + i + '-' + matchIndex; | ||
match.type = kind; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here I use the field name as the type
I'll think of an introductory example, but I'm not much of a javascript programmer, so my examples might be rather limited. |
It doesn't have to be a real life parsing and stuff, just a function match which returns a "match". Should be enough to get started! An entry from the specs might do it |
I added a new example and a spec testing the example |
I'm totally happy with the code and docs now. |
|
fs.writeFileSync(directory + 'change_dir_output.txt', fs.readFileSync(__dirname + '/fixture/change_dir_output.txt')); | ||
fs.mkdirSync(directory + 'foo'); | ||
fs.mkdirSync(directory + 'foo/src'); | ||
fs.writeFileSync(directory + 'foo/src/testmake.c', 'lorem ipsum\naquarium laudanum\nbabaorum petibonum\nthe cake is a lie'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be the issue. Should probably use path.join
.
atom still keeps a handle on a file in the directory while we try to delete the directory after each spec run. This issue is talked about here: isaacs/rimraf#72 Not sure how to fix this, because I have no idea how to close a tab in code. And even then, atom might keep the handle longer than it should. Can we just stop deleting the specs after running them? They are in a temp directory with a unique id anyway. |
But this only happened after your last change. Oh I just saw you added that test |
I'm actually creating subdirectories. Atom might somehow lock them. |
The stack trace is originating from https://github.com/noseglid/atom-build/blob/master/spec/build-error-match-spec.js#L55. |
That's what I meant, for simplicity we can just not clean up at all :) It's not like we're producing huge files during the specs. |
I'd feel better with a try-catch than completely removing it though. When I do development I could potentially end up with a lot of temporary files which could've been cleaned up |
on windows atom might still have handles to the directory/files if it has a file open in a subdirectory
Just put a comment in the catch
run |
I edited it through the github interface b/c I wasn't on a pc that I had set up ;) |
Merged! Thanks so much for this and all your patience! |
This adds
warningMatch
and improvesfunctionMatch
to allow build providers to emit almost any kind of lint that is specified here: https://github.com/steelbrain/linter/wiki/Linter-API#messagesAn example of a modified
![pic of traces and custom error types](https://cloud.githubusercontent.com/assets/332036/15097688/ddfc170c-1523-11e6-8394-d24a79d125ea.png)
build-cargo
:fixes #408