diff --git a/hash.c b/hash.c index 182f41a288adab..41d5a1dfe61bdd 100644 --- a/hash.c +++ b/hash.c @@ -712,7 +712,7 @@ ar_force_convert_table(VALUE hash, const char *file, int line) RUBY_ASSERT(rb_gc_obj_slot_size(hash) >= sizeof(struct RHash) + sizeof(ar_table)); // prepare hash values - do { + while (1) { st_data_t keys[RHASH_AR_TABLE_MAX_SIZE]; bound = RHASH_AR_TABLE_BOUND(hash); size = RHASH_AR_TABLE_SIZE(hash); @@ -727,7 +727,9 @@ ar_force_convert_table(VALUE hash, const char *file, int line) if (UNLIKELY(!RHASH_AR_TABLE_P(hash))) return RHASH_ST_TABLE(hash); if (UNLIKELY(RHASH_AR_TABLE_BOUND(hash) != bound)) continue; if (UNLIKELY(ar_each_key(ar, bound, ar_each_key_cmp, keys, NULL, NULL))) continue; - } while (0); + + break; + } // make st st_table tab; diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 0d37f89772fb3c..ac37929386592c 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -403,10 +403,6 @@ def write_lock(file, preserve_unknown_sections) contents = to_lock - # Convert to \r\n if the existing lock has them - # i.e., Windows with `git config core.autocrlf=true` - contents.gsub!(/\n/, "\r\n") if @lockfile_contents.match?("\r\n") - if @locked_bundler_version locked_major = @locked_bundler_version.segments.first current_major = bundler_version_to_lock.segments.first @@ -427,6 +423,14 @@ def write_lock(file, preserve_unknown_sections) return end + # Convert to \r\n if the existing lock has them, i.e., Windows with + # `git config core.autocrlf=true`. Detect from the bytes on disk because + # reading in text mode strips carriage returns on Windows, which would + # otherwise defeat this check and rewrite a `\r\n` lockfile with `\n`. + if File.exist?(file) && SharedHelpers.filesystem_access(file, :read) {|p| File.binread(p).include?("\r\n") } + contents.gsub!(/\n/, "\r\n") + end + begin SharedHelpers.filesystem_access(file) do |p| File.open(p, "wb") {|f| f.puts(contents) } diff --git a/spec/bundler/install/deploy_spec.rb b/spec/bundler/install/deploy_spec.rb index a3b4a87ecfaa8d..5bdb8f6194f518 100644 --- a/spec/bundler/install/deploy_spec.rb +++ b/spec/bundler/install/deploy_spec.rb @@ -44,8 +44,6 @@ end it "works when you bundle exec bundle" do - skip "doesn't find bundle" if Gem.win_platform? - bundle :install bundle_config "deployment true" bundle :install diff --git a/spec/bundler/install/gemfile/git_spec.rb b/spec/bundler/install/gemfile/git_spec.rb index f2138b5fda2088..ee4c91a4f2b4a6 100644 --- a/spec/bundler/install/gemfile/git_spec.rb +++ b/spec/bundler/install/gemfile/git_spec.rb @@ -427,8 +427,6 @@ context "when the branch starts with a `#`" do let(:branch) { "#149/redirect-url-fragment" } it "works" do - skip "git does not accept this" if Gem.win_platform? - update_git("foo", path: repo, branch: branch) install_gemfile <<-G @@ -481,8 +479,6 @@ context "when the tag starts with a `#`" do let(:tag) { "#149/redirect-url-fragment" } it "works" do - skip "git does not accept this" if Gem.win_platform? - update_git("foo", path: repo, tag: tag) install_gemfile <<-G diff --git a/spec/bundler/install/yanked_spec.rb b/spec/bundler/install/yanked_spec.rb index fb9316cced8a4c..02c1c360be7714 100644 --- a/spec/bundler/install/yanked_spec.rb +++ b/spec/bundler/install/yanked_spec.rb @@ -54,8 +54,6 @@ end before do - skip "Materialization on Windows is not yet strict, so the example does not detect the gem has been yanked" if Gem.win_platform? - build_repo4 do build_gem "foo", "1.0.0" build_gem "foo", "1.0.1" diff --git a/spec/bundler/lock/lockfile_spec.rb b/spec/bundler/lock/lockfile_spec.rb index 84b74823d47759..3ee0705c652e22 100644 --- a/spec/bundler/lock/lockfile_spec.rb +++ b/spec/bundler/lock/lockfile_spec.rb @@ -2335,9 +2335,7 @@ def set_lockfile_mtime_to_known_value expect(the_bundle).to include_gems "myrack 1.2" end - it "preserves Gemfile.lock \\n\\r line endings" do - skip "needs to be adapted" if Gem.win_platform? - + it "preserves Gemfile.lock \\r\\n line endings" do update_repo2 do build_gem "myrack", "1.2" do |s| s.executables = "myrackup" @@ -2349,7 +2347,7 @@ def set_lockfile_mtime_to_known_value set_lockfile_mtime_to_known_value expect { bundle "update", all: true }.to change { File.mtime(bundled_app_lock) } - expect(File.read(bundled_app_lock)).to match("\r\n") + expect(File.binread(bundled_app_lock)).to match("\r\n") expect(the_bundle).to include_gems "myrack 1.2" end @@ -2365,7 +2363,7 @@ def set_lockfile_mtime_to_known_value end.not_to change { File.mtime(bundled_app_lock) } end - it "preserves Gemfile.lock \\n\\r line endings" do + it "preserves Gemfile.lock \\r\\n line endings" do win_lock = File.read(bundled_app_lock).gsub(/\n/, "\r\n") File.open(bundled_app_lock, "wb") {|f| f.puts(win_lock) } set_lockfile_mtime_to_known_value diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index feffe36aae028d..91aad11da97d6d 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -194,8 +194,14 @@ def test_stat_argument def test_stat_single omit 'stress' if GC.stress - stat = GC.stat - assert_equal stat[:count], GC.stat(:count) + # GC.stat and GC.stat(:count) are two separate reads of :count. If a GC + # runs between them (e.g. triggered by an allocation on another thread), + # :count changes and the two reads disagree. Disable GC so both reads + # observe the same :count. + EnvUtil.without_gc do + stat = GC.stat + assert_equal stat[:count], GC.stat(:count) + end assert_raise(ArgumentError){ GC.stat(:invalid) } end