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

Add profile to rebar3 for erlang #1560

Merged
merged 1 commit into from May 3, 2019

Conversation

dgud
Copy link
Contributor

@dgud dgud commented Apr 4, 2019

To be able to compile test files profile needs to be set to "test",
with the "default" profile test files are not compiled.

Test files are found in the application "test" sub-directory.

@CLAassistant
Copy link

CLAassistant commented Apr 4, 2019

CLA assistant check
All committers have signed the CLA.

@dgud
Copy link
Contributor Author

dgud commented Apr 4, 2019

Or is there a better solution? @joedevivo @tsloughter

@dgud
Copy link
Contributor Author

dgud commented Apr 4, 2019

And I need some help with the travis errors, which I don't understand.

@tsloughter
Copy link

So this uses the test profile only if the file being modified is in a test directory?

@fmdkdd
Copy link
Member

fmdkdd commented Apr 4, 2019

So this uses the test profile only if the file being modified is in a test directory?

Only if the file being modified is in a directory named "test" rather. My question is then: does Erlang/rebar forces to name your test directory "test", or are you free to name it something else?

@tsloughter
Copy link

rebar3 defaults to looking in "test" and Erlang convention is "test".

I don't know that I've seen a different directory used before. The only thing is this won't technically catch all modification of test code because some put unit tests directly in the module being tested with macros:

-ifdef(TEST).
... unit tests...
-endif.

TEST is set by the test profile. So if the user is modifying a unit test like this it would still compile in the default profile. But I don't think this should stop the change.

@fmdkdd
Copy link
Member

fmdkdd commented Apr 5, 2019

TEST is set by the test profile. So if the user is modifying a unit test like this it would still compile in the default profile.

And there's no way to run the test profile alongside the default one? Or maybe the test profile is a superset of the default one?

@dgud
Copy link
Contributor Author

dgud commented Apr 5, 2019

I do think the only difference for rebar (when profile is test) is to define TEST macro and compile files (including files in test dir) but Tristan knows this better, I'm just guessing here.

@fmdkdd
Copy link
Member

fmdkdd commented Apr 5, 2019

Why I'm asking is that the usual way we would provide the functionality of this PR would be through a new variable flycheck-rebar3-profile, which would be test or default. Then we would usually let a Flycheck extension (another package, which defines a function that would be added to flycheck-mode-hook) set the value of this variable depending on the current buffer (here, using the buffer filename).

The advantage of using a variable instead of the (eval (rebar3-profile)) is that a variable can be set manually, through buffer- or file-locals, and can be overridden easily.

The downside is that you would need to write and publish a separate extension, just for a very simple function, which seems a bit silly.

If you feel that there is no valid use case for customizing the behavior of the rebar3-profile, then we don't need a variable and can go through with your implementation.

@dgud
Copy link
Contributor Author

dgud commented Apr 6, 2019

Hmm, thinking about what you wrote, why can't we always run with the 'test' profile?
Could there be a problem with that @tsloughter ?

:command ("rebar3" "as" "test" "compile")

@tsloughter
Copy link

That is what I thought this PR was at first. I'm not sure it is a good default. Maybe most people will want it that way, either way if it is default or not it should be easily configurable.

@fmdkdd
Copy link
Member

fmdkdd commented Apr 8, 2019

either way if it is default or not it should be easily configurable.

Then in that case we can more simply have a configurable variable for the profile to use, with default as the default value. No need to check the directory the file resides in.

@tsloughter
Copy link

Eh, I like the use of test profile if you are in the test directory. It should be configurable for those who want to always use the test profile, for instance if they include tests in modules directly.

@fmdkdd
Copy link
Member

fmdkdd commented Apr 9, 2019

Okay so we want the profile to be user-configurable, and if the user doesn't say anything, we look at the directory like this PR does right now.

@dgud Can you add a flycheck-def-option-var for rebar3's profile? The default should be nil, and it acceptable values would be default and test (for the :type of defcustom). Then, in rebar3-profile, you would check that variable's value: if it's set, use that value for the profile, otherwise fallback on auto-detection using the directory name.

Sounds good?

@tsloughter
Copy link

Yup, that'd be great.

@dgud
Copy link
Contributor Author

dgud commented Apr 10, 2019

Yeah I can try, give me a couple of days, I've been sick so it will take a while until I caught up with things.

@fmdkdd
Copy link
Member

fmdkdd commented Apr 10, 2019

@dgud No pressure; please take time to recover. This PR isn't going anywhere ;)

@dgud
Copy link
Contributor Author

dgud commented Apr 18, 2019

Some questions, are there more profiles we should support or are they user defined 'prod'/'native' @tsloughter ?

What should package-version be?

And please review my lisp code and comments I'm not fluent in either language :-)

@fmdkdd
Copy link
Member

fmdkdd commented Apr 18, 2019

What should package-version be?

  1. You can look at the top of the file: "32-cvs" means we are currently working towards version 32.

flycheck.el Outdated Show resolved Hide resolved
flycheck.el Outdated Show resolved Hide resolved
flycheck.el Show resolved Hide resolved
flycheck.el Outdated
(symbol-name flycheck-erlang-rebar3-profile))
((and buffer-file-name
(string= "test" (file-name-base (directory-file-name
(file-name-directory buffer-file-name)))))
Copy link
Member

Choose a reason for hiding this comment

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

You want to line feed after "test" and reindent in order to pass the make check test.

@fmdkdd
Copy link
Member

fmdkdd commented Apr 24, 2019

Thanks for the changes. You'll need to document the new option in the manual as well to pass the CI. Add a defcustom line in doc/languages.rst (see other checkers around for examples).

@dgud
Copy link
Contributor Author

dgud commented Apr 24, 2019

Ah wait, do we want the user to be able to provide an arbitrary profile beyond default and test or not?

That was the question to @tsloughter ?

@fmdkdd
Copy link
Member

fmdkdd commented Apr 24, 2019

That was the question to @tsloughter ?

Yes indeed. If we do want more profiles then we may want to use strings instead for the option, and allow for an arbitrary (string case. If we only care about test and default, then we can stick to symbols.

@tsloughter
Copy link

@fmdkdd that could be useful, yea, good idea.

@dgud
Copy link
Contributor Author

dgud commented Apr 29, 2019

Changed to arbitrary strings.

@fmdkdd
Copy link
Member

fmdkdd commented Apr 30, 2019

LGTM. Please add a line to CHANGES.rst introducing the new option.

@dgud dgud force-pushed the dgud/erlang-rebar3-fix-test branch from 793dff4 to 5ac1096 Compare May 3, 2019 08:20
To be able to compile test files profile needs to be set to "test",
with the "default" profile test files are not compiled.

Test files are found in the application "test" sub-directory.
@dgud dgud force-pushed the dgud/erlang-rebar3-fix-test branch from 5ac1096 to 02ca36f Compare May 3, 2019 08:23
@dgud
Copy link
Contributor Author

dgud commented May 3, 2019

Added line to Changes, squashed commits and rebased to master.

@fmdkdd fmdkdd merged commit 47174a1 into flycheck:master May 3, 2019
@fmdkdd
Copy link
Member

fmdkdd commented May 3, 2019

Nice work! Thank you. 👏

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.

None yet

4 participants