Skip to content

Commit 92617c5

Browse files
committed
Merge pull request #9580 from ruby/scrub-invalid-utf8-command-output
Fixed flaky tests (cherry picked from commit dce4b75)
1 parent bd0f525 commit 92617c5

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

bundler/lib/bundler/source/git/git_proxy.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,14 @@ def capture(cmd, dir, ignore_err: false)
432432
end
433433

434434
def capture3_args_for(cmd, dir)
435-
return ["git", *cmd] unless dir
435+
# Disable automatic maintenance so a background commit-graph write in
436+
# the source repo can't race the hardlinking local clone and fail with
437+
# "hardlink different from source".
438+
opts = ["-c", "gc.auto=0", "-c", "maintenance.auto=false"]
436439

437-
["git", "-C", dir.to_s, *cmd]
440+
return ["git", *opts, *cmd] unless dir
441+
442+
["git", "-C", dir.to_s, *opts, *cmd]
438443
end
439444

440445
def extra_clone_args

bundler/spec/support/command_execution.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def failure?
7272
attr_reader :failure_reason
7373

7474
def normalize(string)
75-
string.force_encoding(Encoding::UTF_8).strip.gsub("\r\n", "\n")
75+
string.dup.force_encoding(Encoding::UTF_8).scrub.strip.gsub("\r\n", "\n")
7676
end
7777
end
7878
end

test/rubygems/test_gem_commands_owner_command.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,6 @@ def test_with_webauthn_enabled_success
399399
end
400400

401401
def test_with_webauthn_enabled_failure
402-
pend "Flaky on TruffleRuby" if RUBY_ENGINE == "truffleruby"
403402
response_success = "Owner added successfully."
404403
server = Gem::MockTCPServer.new
405404
error = Gem::WebauthnVerificationError.new("Something went wrong")
@@ -417,7 +416,8 @@ def test_with_webauthn_enabled_failure
417416
end
418417
end
419418

420-
assert_match @stub_fetcher.last_request["Authorization"], Gem.configuration.rubygems_api_key
419+
webauthn_verification_request = @stub_fetcher.requests.find {|req| req.path == "/api/v1/webauthn_verification" }
420+
assert_match webauthn_verification_request["Authorization"], Gem.configuration.rubygems_api_key
421421
assert_match "You have enabled multi-factor authentication. Please visit the following URL " \
422422
"to authenticate via security device. If you can't verify using WebAuthn but have OTP enabled, " \
423423
"you can re-run the gem signin command with the `--otp [your_code]` option.", @stub_ui.output

0 commit comments

Comments
 (0)