-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
shebang: raise error if no rewriting
- Loading branch information
1 parent
397afb6
commit 7e6be5e
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# typed: false | ||
# frozen_string_literal: true | ||
|
||
require "utils/shebang" | ||
|
||
describe Utils::Shebang do | ||
let(:file) { Tempfile.new("shebang") } | ||
|
||
before do | ||
file.write "#!/usr/bin/python" | ||
file.flush | ||
end | ||
|
||
after { file.unlink } | ||
|
||
describe "rewrite_shebang" do | ||
it "rewrites a shebang" do | ||
rewrite_info = Utils::Shebang::RewriteInfo.new(/^#!.*python$/, 25, "new_shebang") | ||
described_class.rewrite_shebang rewrite_info, file | ||
expect(File.read(file)).to eq "#!new_shebang" | ||
end | ||
|
||
it "raises an error if no rewriting occurs" do | ||
rewrite_info = Utils::Shebang::RewriteInfo.new(/^#!.*perl$/, 25, "new_shebang") | ||
expect { | ||
described_class.rewrite_shebang rewrite_info, file | ||
}.to raise_error("No matching files found to rewrite shebang") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7e6be5e
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 badly breaks many packages that pass a large list of paths (one at a time) and do not expect them all to succeed. Such as
glib
...:The files it loops over:
This will fail on the very first item because it's a path, not a file...