summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBundlerbot <bot@bundler.io>2019-02-15 22:14:22 +0000
committerBundlerbot <bot@bundler.io>2019-02-15 22:14:22 +0000
commit5ebdd9969a72daf457270fe927d6cae46ca37a58 (patch)
tree1edd006838fb5bd56f99a7492683aeeb9b801161
parent9b56229a4015e3eca554b1867a06ac683feda362 (diff)
parent8ace8a56cdc75bba5fcfc65fc65545de4e99e824 (diff)
downloadbundler-5ebdd9969a72daf457270fe927d6cae46ca37a58.tar.gz
Merge #6899
6899: Windows CI: Azure Pipelines r=colby-swandale a=janpio ### What was the end-user problem that led to this PR? When I wanted to start to work on #6841 by adding a few tests, I quickly learned that bundler's test suite does not pass on Windows: #6868 ### What was your diagnosis of the problem? I decided to start working on fixing this, and created a few issues already: https://github.com/bundler/bundler/search?q=%22%5BWindows+test+failure%5D%22&unscoped_q=%22%5BWindows+test+failure%5D%22&type=Issues But it become clear to me, that the only way to really track the improvement was to add CI for Windows - otherwise opening PRs with improvements would not really make sense. ### What is your fix for the problem, implemented in this PR? This PR first makes it possible to run the test suite on Windows at all by "hiding" a bit of code behind `Gem.win_platform?` (`Spec::Manpages.setup` made it super complicated to run on Windows - and is not really necessary to run the test suite). It also works around a strange bug concerning `thor`'s (a vendored dependency) use of `readline` which crashes in strange ways on Windows (see #6902). And it adds applies a patch to the `readline` implementation used on CI (via RubyInstaller ruby) that otherwise blocks the tests (see #6907). Then it adds CI configuration for Azure Pipelines, a free for OSS CI platform. I configured the Azure Pipelines build to create a JUnit compatible report if the test suite and display it in the "Tests" tab of the build. ### Why did you choose this fix out of the possible options? I think disabling this code for Windows is a valid choice to get the ball rolling, later this will undone and the underlying problem will be fixed. I chose the workarounds for #6902 and #6907 as I couldn't find a proper bugfix yet - so this will be one of the things to be fixed using Windows CI. Azure Pipelines is a great CI platform for Windows (and later even multiple platforms if we choose to also run the tests on Linux and macOS). I chose not to adapt the `rake travis` task (yet) because it is _much_ more complex than the "simple" `bin/rspec` test suite run which I could directly execute in the CI scripts of Azure Pipelines. Co-authored-by: Jan Piotrowski <piotrowski+git@gmail.com> Co-authored-by: Jan Piotrowski <piotrowski+github@gmail.com>
-rw-r--r--azure-pipelines.yml6
-rw-r--r--azure-pipelines/rbreadline.diff41
-rw-r--r--azure-pipelines/steps.yml39
-rw-r--r--spec/spec_helper.rb2
4 files changed, 87 insertions, 1 deletions
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
new file mode 100644
index 0000000000..9d1535f8cd
--- /dev/null
+++ b/azure-pipelines.yml
@@ -0,0 +1,6 @@
+jobs:
+- job: Windows
+ pool:
+ vmImage: 'vs2017-win2016'
+ steps:
+ - template: azure-pipelines/steps.yml
diff --git a/azure-pipelines/rbreadline.diff b/azure-pipelines/rbreadline.diff
new file mode 100644
index 0000000000..c139577610
--- /dev/null
+++ b/azure-pipelines/rbreadline.diff
@@ -0,0 +1,41 @@
+diff --git a/rbreadline.rb b/rbreadline.rb
+index c710961..e35408c 100644
+--- a/rbreadline.rb
++++ b/rbreadline.rb
+@@ -16,6 +16,7 @@ end
+
+ module RbReadline
+ require 'etc'
++ require 'io/console'
+
+ RL_LIBRARY_VERSION = "5.2"
+ RL_READLINE_VERSION = 0x0502
+@@ -1092,6 +1093,9 @@ module RbReadline
+ @current_readline_init_include_level = 0
+ @current_readline_init_lineno = 0
+
++ # Used in windows
++ @is_pipe = false
++
+ ENV["HOME"] ||= "#{ENV["HOMEDRIVE"]}#{ENV["HOMEPATH"]}"
+ if !File.directory? ENV["HOME"]
+ raise RuntimeError.new("HOME environment variable (or HOMEDRIVE and HOMEPATH) must be set and point to a directory")
+@@ -4490,6 +4494,10 @@ module RbReadline
+ end
+
+ def rl_getc(stream)
++ # below added as test for whether we're connected to a pipe or a keyboard.
++ # Pipe connection is probably running under a test suite.
++ return (stream.getc || EOF rescue EOF) if @is_pipe
++
+ while (@kbhit.Call == 0)
+ # If there is no input, yield the processor for other threads
+ sleep(@_keyboard_input_timeout)
+@@ -4740,6 +4748,7 @@ module RbReadline
+ def readline_internal_charloop()
+ lastc = -1
+ eof_found = false
++ @is_pipe = (!@rl_outstream.winsize rescue true)
+
+ while (!@rl_done)
+ lk = @_rl_last_command_was_kill
diff --git a/azure-pipelines/steps.yml b/azure-pipelines/steps.yml
new file mode 100644
index 0000000000..548847c910
--- /dev/null
+++ b/azure-pipelines/steps.yml
@@ -0,0 +1,39 @@
+steps:
+
+- task: UseRubyVersion@0
+ inputs:
+ versionSpec: '= 2.4'
+
+- script: |
+ ruby -v
+ ridk version
+ displayName: 'ruby -v + ridk version'
+
+- script: |
+ mkdir tmp
+ cd tmp
+ mkdir home
+ displayName: 'work around readline crash (for https://github.com/bundler/bundler/issues/6902)'
+
+- script: |
+ git apply --ignore-space-change --ignore-whitespace azure-pipelines\rbreadline.diff --directory=C:/hostedtoolcache/windows/Ruby/2.4.3/x64/lib/ruby/site_ruby --unsafe-paths
+ displayName: 'patch local readline implementation (for https://github.com/bundler/bundler/issues/6907)'
+
+- script: |
+ ruby bin/rake spec:deps
+ displayName: 'ruby bin/rake spec:deps'
+
+- script: |
+ gem install --no-document --conservative rspec_junit_formatter
+ displayName: 'gem install rspec_junit_formatter'
+
+- script: |
+ ruby -r rspec_junit_formatter bin/rspec --format progress --format RspecJunitFormatter -o rspec/bundler-junit-results.xml || exit 0
+ displayName: 'ruby bin/rspec'
+
+- task: PublishTestResults@2
+ inputs:
+ testRunner: JUnit
+ testResultsFiles: rspec/bundler-junit-results.xml
+ displayName: Publish test results
+ condition: succeededOrFailed()
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 9355bfb33f..7cc363087c 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -41,7 +41,7 @@ end
$debug = false
-Spec::Manpages.setup
+Spec::Manpages.setup unless Gem.win_platform?
Spec::Rubygems.setup
FileUtils.rm_rf(Spec::Path.gem_repo1)
ENV["RUBYOPT"] = "#{ENV["RUBYOPT"]} -r#{Spec::Path.spec_dir}/support/hax.rb"