Skip to content
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

Merged
merged 21 commits into from
May 12, 2016

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented May 8, 2016

This adds warningMatch and improves functionMatch to allow build providers to emit almost any kind of lint that is specified here: https://github.com/steelbrain/linter/wiki/Linter-API#messages

An example of a modified build-cargo:
pic of traces and custom error types

fixes #408

@oli-obk oli-obk changed the title enable traces (sub-errors) and custom "error types" enable traces (sub/child-errors) and custom "error types" May 8, 2016
require('xregexp').forEach(this.output, regex, matchFunction.bind(this.currentMatch));

// first run all functional matches
this.functions && this.functions.forEach((f, functionIndex) => {
Copy link
Owner

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

@noseglid
Copy link
Owner

noseglid commented May 9, 2016

This amount of code almost warrants moving all linter related code to a linter-integration.js file.

@oli-obk
Copy link
Contributor Author

oli-obk commented May 10, 2016

I removed the criticality, and am parsing the type now. I added a few possible type values. Matches with unknown type are turned into error, Children of matches with unknown type are turned into info.

@oli-obk
Copy link
Contributor Author

oli-obk commented May 10, 2016

This amount of code almost warrants moving all linter related code to a linter-integration.js file.

I tried that, I failed (or the linter-integration specs did at least), not sure what I did wrong.

@oli-obk
Copy link
Contributor Author

oli-obk commented May 10, 2016

nevermind, I found it :) works now

specs are very weird with their error reporting. Most non-assertion errors just disappear into the void

@noseglid
Copy link
Owner

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)
Copy link
Owner

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?

Copy link
Contributor Author

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.

Copy link
Owner

Choose a reason for hiding this comment

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

Allright, makes sense!

@noseglid
Copy link
Owner

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;
Copy link
Contributor Author

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

@oli-obk
Copy link
Contributor Author

oli-obk commented May 11, 2016

I'll think of an introductory example, but I'm not much of a javascript programmer, so my examples might be rather limited.

@noseglid
Copy link
Owner

noseglid commented May 11, 2016

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

@oli-obk
Copy link
Contributor Author

oli-obk commented May 12, 2016

I added a new example and a spec testing the example

@noseglid
Copy link
Owner

I'm totally happy with the code and docs now.
Something broke on Windows though :(

@oli-obk
Copy link
Contributor Author

oli-obk commented May 12, 2016

probably the / path separators, I'll investigate

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');
Copy link
Owner

@noseglid noseglid May 12, 2016

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.

@oli-obk
Copy link
Contributor Author

oli-obk commented May 12, 2016

Error Match
  when using function matches
    it should be possible to keep state from previous lines
      Error: ENOTEMPTY: directory not empty, rmdir 'C:\Users\appveyor\AppData\Local\Temp\1\atom-build-spec-116412-2472-1nu667v\foo'
        Error: ENOTEMPTY: directory not empty, rmdir 'C:\Users\appveyor\AppData\Local\Temp\1\atom-build-spec-116412-2472-1nu667v\foo'
        at Error (native)
        at Object.fs.rmdirSync (fs.js:806:18)
        at rmkidsSync (C:\projects\atom-build\node_modules\fs-extra\node_modules\rimraf\rimraf.js:334:11)
        at rmdirSync (C:\projects\atom-build\node_modules\fs-extra\node_modules\rimraf\rimraf.js:324:7)
        at rimrafSync (C:\projects\atom-build\node_modules\fs-extra\node_modules\rimraf\rimraf.js:295:9)
        at C:\projects\atom-build\node_modules\fs-extra\node_modules\rimraf\rimraf.js:332:5
        at Array.forEach (native)
        at rmkidsSync (C:\projects\atom-build\node_modules\fs-extra\node_modules\rimraf\rimraf.js:331:26)
        at rmdirSync (C:\projects\atom-build\node_modules\fs-extra\node_modules\rimraf\rimraf.js:324:7)
        at Function.rimrafSync [as sync] (C:\projects\atom-build\node_modules\fs-extra\node_modules\rimraf\rimraf.js:295:9)
        at Object.removeSync (C:\projects\atom-build\node_modules\fs-extra\lib\remove\index.js:4:17)
        at [object Object].<anonymous> (C:/projects/atom-build/spec/build-error-match-spec.js:58:8)

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.

@noseglid
Copy link
Owner

noseglid commented May 12, 2016

But this only happened after your last change.

Oh I just saw you added that test

@oli-obk
Copy link
Contributor Author

oli-obk commented May 12, 2016

I'm actually creating subdirectories. Atom might somehow lock them.

@noseglid
Copy link
Owner

noseglid commented May 12, 2016

The stack trace is originating from https://github.com/noseglid/atom-build/blob/master/spec/build-error-match-spec.js#L55.
I'd suggest putting a try-catch around that, if we fail to clean up, buhoo. It'll all work anyway and the next tests gets a new temporary directory anyway.

@oli-obk
Copy link
Contributor Author

oli-obk commented May 12, 2016

I'd suggest putting a try-catch around that, if we fail to clean up, buhoo. It'll all work anyway and the next tests gets a new temporary directory anyway.

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.

@noseglid
Copy link
Owner

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

oli-obk added 2 commits May 12, 2016 16:25
on windows atom might still have handles to the directory/files if it has a file open in a subdirectory
@noseglid
Copy link
Owner

Just put a comment in the catch

catch (err) {
  // Failed to clean up, ignore this.
}

run npm test locally to lint check it.

@oli-obk
Copy link
Contributor Author

oli-obk commented May 12, 2016

I edited it through the github interface b/c I wasn't on a pc that I had set up ;)

@noseglid noseglid merged commit 0c3106e into noseglid:master May 12, 2016
@noseglid
Copy link
Owner

Merged! Thanks so much for this and all your patience!

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.

Support warnings in addition to errors
2 participants