Git commit 60d523b9a7726560f2a1fb1fb0919b726434ff95 by Cornelius Schumacher. Committed on 15/10/2016 at 10:24. Pushed by cschumac into branch 'master'. Gracefully fail if Qt is not found M +13 -4 lib/cli_controller.rb A +2 -0 spec/stubs/qmake/qmake M +28 -5 spec/unit/cli_controller_spec.rb M +4 -0 spec/unit/spec_helper.rb http://commits.kde.org/websites/inqlude/60d523b9a7726560f2a1fb1fb0919b72643= 4ff95 diff --git a/lib/cli_controller.rb b/lib/cli_controller.rb index 86c8a92..9a8b599 100644 --- a/lib/cli_controller.rb +++ b/lib/cli_controller.rb @@ -2,14 +2,23 @@ class CliController def self.print_versions(distro) puts "Inqlude: #{Inqlude::VERSION}" = - qmake_out =3D `qmake -v` - qmake_out =3D~ /Qt version (.*) in/ - puts "Qt: #{$1}" + if find_executable("qmake") + qmake_out =3D `qmake -v` + qmake_out =3D~ /Qt version (.*) in/ + puts "Qt: #{$1}" + else + puts "Qt: not found" + end = if distro puts "OS: #{distro.name} #{distro.version}" else puts "OS: unknown" end - end = + end + + def self.find_executable(executable) + `which #{executable}` + $?.success? + end end diff --git a/spec/stubs/qmake/qmake b/spec/stubs/qmake/qmake new file mode 100755 index 0000000..665b48e --- /dev/null +++ b/spec/stubs/qmake/qmake @@ -0,0 +1,2 @@ +echo QMake version 2.01a +echo Using Qt version 4.8.6 in /usr/lib64hello diff --git a/spec/unit/cli_controller_spec.rb b/spec/unit/cli_controller_sp= ec.rb index 94a882e..bb9a42a 100644 --- a/spec/unit/cli_controller_spec.rb +++ b/spec/unit/cli_controller_spec.rb @@ -14,15 +14,38 @@ describe CliController do let(:distro) {DistroUnknown.new} = describe ".print_versions" do - it "prints versions" do - expected_output =3D < EOT - expect { - CliController.print_versions(distro) - }.to output(expected_output).to_stdout + expect { + CliController.print_versions(distro) + }.to output(expected_output).to_stdout + end + end + + context "without qmake installed" do + before do + allow(CliController).to receive(:find_executable).with("qmake").an= d_return(false) + end + + it "prints versions" do + expected_output =3D < +EOT + expect { + CliController.print_versions(distro) + }.to output(expected_output).to_stdout + end end end end diff --git a/spec/unit/spec_helper.rb b/spec/unit/spec_helper.rb index 918aae0..453b5ca 100644 --- a/spec/unit/spec_helper.rb +++ b/spec/unit/spec_helper.rb @@ -12,6 +12,10 @@ def test_data_path file_name File.expand_path(File.join('../../data/', file_name), __FILE__) end = +def stubs_path(context) + File.expand_path(File.join('../../stubs/', context), __FILE__) +end + def create_manifest name, release_date, version m =3D ManifestRelease.new m.name =3D name