Skip to content

Commit

Permalink
Merge pull request #34 from liaogz82/improve-error-msg
Browse files Browse the repository at this point in the history
Improve error communication
  • Loading branch information
mosesliao committed Oct 31, 2018
2 parents 26b5e0f + c0bb4bf commit 5a471c9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions codecov.yml
@@ -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
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
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

0 comments on commit 5a471c9

Please sign in to comment.