-
-
Notifications
You must be signed in to change notification settings - Fork 525
file mode changes #289
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
file mode changes #289
Conversation
Looks good. Waiting on Travis. |
Methods can't go to 11! |
You shouldn't need to change folders into any other folder in order to use the tools. In fact you should be able to add that (the bin folder) to your path and run them from anywhere. Though normally, I suppose, it would be the project root. You don't change directory to work on the exercise files, (do you?) you shouldn't need to run the bin files. |
Its not that you need to cd to use them, its that if you do, you can't! |
@kotp, are you against having |
if File.executable?(f) | ||
print '.' | ||
else | ||
print "Adding exec bit to #{f}." | ||
File.chmod(0744, f) | ||
File.chmod(0775, f) |
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.
Why the expanded privileges here? 744 should be fine, and technically more permissive even than necessary.
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.
These are the permissions of current executables, so I updated the chmod
for consistency.
Actually, putting |
I guess I just don't change into folders, to have noticed it. I set the permissions to be minimally permissive, and even 744 is maybe more than is needed. Realize that the git hooks are using (some of) these files too. (see |
Just pushed my latest changes up. Let me know what you think. |
Current view on that branch looks like:
Your changes introduce another level of access that may not be necessary. Compare to the rest of the files permissions. Yours are 775, while the rest are 744. |
A fresh clone of master has this for me:
|
But that wasn't coming from the prior version. I just checked against what it was handling, which is the test files... I get this:
for example, which is to say 744. |
It appears there is some git magic afoot. I'll update to using |
Should be all squared away now. /knocks on wood |
File.open(path_to("#{name.gsub(/[ -]/, '_')}_test.rb"), 'w') do |f| | ||
f.write ERB.new(File.read(path_to('example.tt'))).result binding | ||
FileUtils.chmod('+x', f) |
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.
Is this available in all languages? We should leave the file executable bit to the helper tool in bin. It is outside the concern of the generator.
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.
When you say all languages do you mean on all platforms?
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.
I gather that this will either be a no-op or will work on Windows, depending on who you ask. The docs don't really say either way. But it definitely shouldn't blow up.
@kotp I'm curious as to why you think we shouldn't change the file mode here?
My argument for changing it here is that it will relieve contributors from the burden of having to remember to run another script or chmod
it themselves. People will predictably forget to chmod the file and we will have to tell them to update it. Or, people might manually change the file mode in weird ways. This standardizes the file mode automatically.
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.
Yes, yes, I do. Specifically, does this exclude Windows.
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.
@Cohen-Carlisle, the enable executable tool does the same thing though, correct? And it is specific to its responsibility.
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.
The nice thing about this is that you will often generate the file a few times while working iteratively toward a solution. This makes it so that you don't even have to worry about the file mode each time you generate the test file.
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.
I understand and can see that it would be a convenience.
If this is to be changed, I would think it should be a different pull request.
If the current pull request would need to be reverted for any reason, it would not effect pulling this change, which I consider to be unrelated.
I think the generator file doesn't belong in this commit? Seems out of place, and I think it naturally leaves if we leave executable bit functionality to the tools to address that. |
I'd rather not have the generator change the file mode, as it seems like a completely unrelated change. The whole "make the tests executable" is a weird edge case that we threw in to make someone happy. I personally do not see the value of it, but it doesn't seem to hurt to have it. That said, at some point I'm going to write an article about all the ways you can run the tests quickly or automatically ( If we stick it in the generators, now we'll have to rip it out of 60 different places. Does that make sense? |
Regarding the test cases being executable or not: I'm sorry to butt in here because I may be making a statement that is based on an incomplete understanding of all the issues at hand here, but I would note that despite https://github.com/exercism/xruby/blob/master/exercises/hello-world/hello_world_test.rb currently being executable (See "Executable file" written on the page), In Basicaly I'm saying, if desiring to make the test files executable, some work will have to be done in CLI. Of course whether the file is executable will affect those who clone the repo directly instead of going through |
Yes, the client code not being executable is understood. Thanks @petertseng, reminded me about that. I am not sure we would or should make clients files executable in general, without good reason. Plus it is one more learning point. How do you automate your tests. I use rerun gem often, or guard when it is a full project. But my editor is my test launcher otherwise. The generator is only one file, and effects those (hopefully soon to be) sixty, but is only one file to change later. Honestly, the benefit is while the generated test is being created. It is a limited convenience. However, the generator change should not be in this PR. |
I forgot about that. We did that on purpose.
Oh, right. I wasn't thinking.
OK, now I really don't understand. Why does it help to make the test file executable when generating it? |
That is more feedback that I have been told, rather than what my experience has been, not sure if they are using automated tools to run on change, or just not using the command line history to get the line So probably too much weight in regards to the benefit being during creation. Though that would be the time when it is likely to be ran in quick succession through the iterations. |
add bin/* files to
enable-executable
andexecutable-status-check
generator now makes test files executable
make
enable-executable
chmod consistent with current file modes