sublime-build: Provide specific prompts for missing GOPATH/GOROOT The new build of sublime-config raises exceptions if the GOPATH or GOROOT can not be found on disk. This update handles these new exceptions and presents them to the user. Change-Id: I4a7589fa9fae8cdf5d2d2025d4ad16026e78f579 Reviewed-on: https://go-review.googlesource.com/16571 Reviewed-by: Jason Buberel <jbuberel@google.com>
diff --git a/dev/tests.py b/dev/tests.py index 87e4b94..2316d05 100644 --- a/dev/tests.py +++ b/dev/tests.py
@@ -442,6 +442,27 @@ self.assertTrue(confirm_user('Were you prompted that GOPATH was not set?')) self.assertTrue(confirm_user('When you pressed "Open Documentation", was it opened in your browser?')) + def test_build_missing_gopath(self): + ensure_not_ui_thread() + + shell, env = shellenv.get_env() + env['GOPATH'] += '12345678' + with GolangBuildMock(shell=shell, env=env): + + file_path = path.join(TEST_GOPATH, 'src', 'good', 'rune_len.go') + + def _run_build(view, result_queue): + notify_user('Press the "Open Documentation" button when prompted about GOPATH not being found') + + view.window().run_command('golang_build') + + custom_view_settings = VIEW_SETTINGS.copy() + del custom_view_settings['GOPATH'] + open_file(file_path, custom_view_settings, _run_build) + time.sleep(0.5) + self.assertTrue(confirm_user('Were you prompted that GOPATH was not found?')) + self.assertTrue(confirm_user('When you pressed "Open Documentation", was it opened in your browser?')) + def ensure_not_ui_thread(): """
diff --git a/golang_build.py b/golang_build.py index c76fcae..ecb0781 100644 --- a/golang_build.py +++ b/golang_build.py
@@ -551,6 +551,23 @@ {'url': 'https://github.com/golang/sublime-build/blob/master/docs/configuration.md'} ) + except (golangconfig.GoRootNotFoundError, golangconfig.GoPathNotFoundError) as e: + error_message = ''' + Golang Build + + %s. + + Would you like to view the configuration documentation? + ''' + + prompt = error_message % str_cls(e) + + if sublime.ok_cancel_dialog(_format_message(prompt), 'Open Documentation'): + window.run_command( + 'open_url', + {'url': 'https://github.com/golang/sublime-build/blob/master/docs/configuration.md'} + ) + return (None, None)