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

Improve error communication #34

Merged
merged 2 commits into from
Oct 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
codecov:
token: 9b033b7b-e22e-45e6-8aba-eccef3026c0e
8 changes: 6 additions & 2 deletions lib/fastlane/plugin/lizard/actions/lizard_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ def self.run(params)
UI.user_error!("You have to install lizard using `[sudo] pip install lizard` or specify the executable path with the `:executable` option.")
end

if params[:executable] && !File.exist?(params[:executable])
UI.user_error!("The custom executable at '#{params[:executable]}' does not exist.")
if params[:executable]
if !File.exist?(params[:executable])
UI.user_error!("The custom executable at '#{params[:executable]}' does not exist.")
elsif !File.file?(params[:executable])
UI.user_error!("You need to point to the executable to lizard.py file!")
end
end

lizard_command = params[:executable].nil? ? "lizard" : "python #{params[:executable]}"
Expand Down
12 changes: 12 additions & 0 deletions spec/lizard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
let(:custom_executable) { "../spec/fixtures/lizard.py" }
let(:outdated_executable) { "../spec/fixtures/outdated_lizard.py" }
let(:newer_executable) { "../spec/fixtures/newer_lizard.py" }
let(:wrong_executable) { "../spec/fixtures" }

context "executable" do
it "fails with invalid sourcemap path" do
Expand Down Expand Up @@ -44,6 +45,17 @@
end").runner.execute(:test)
end

it "should raise if executable is wrong" do
expect(FastlaneCore::UI).to receive(:user_error!).with(/You need to point to the executable to lizard.py file\!/).and_call_original
expect do
Fastlane::FastFile.new.parse("lane :test do
lizard(
executable: '#{wrong_executable}'
)
end").runner.execute(:test)
end.to raise_error(/You need to point to the executable to lizard.py file\!/)
end

it "should raise if executable version is less than required" do
expect(FastlaneCore::UI).to receive(:user_error!).with(/Your lizard version .* is outdated, please upgrade to at least version .* and start your lane again\!/).and_call_original
expect do
Expand Down