提交 d493c91d 编写于 作者: M Michael Kozono

Log push output on exception

上级 0ea5d664
...@@ -13,11 +13,15 @@ module QA ...@@ -13,11 +13,15 @@ module QA
Page::Main::Login.act { sign_in_using_credentials } Page::Main::Login.act { sign_in_using_credentials }
end end
after do after do |example|
# We need to clear localStorage because we're using it for the dropdown, # We need to clear localStorage because we're using it for the dropdown,
# and capybara doesn't do this for us. # and capybara doesn't do this for us.
# https://github.com/teamcapybara/capybara/issues/1702 # https://github.com/teamcapybara/capybara/issues/1702
Capybara.execute_script 'localStorage.clear()' Capybara.execute_script 'localStorage.clear()'
# In order to help diagnose a false failure
# https://gitlab.com/gitlab-org/gitlab-ce/issues/48241
log_push_output if example.exception
end end
context 'when developers and maintainers are allowed to push to a protected branch' do context 'when developers and maintainers are allowed to push to a protected branch' do
...@@ -27,9 +31,9 @@ module QA ...@@ -27,9 +31,9 @@ module QA
expect(protected_branch.name).to have_content(branch_name) expect(protected_branch.name).to have_content(branch_name)
expect(protected_branch.push_allowance).to have_content('Developers + Maintainers') expect(protected_branch.push_allowance).to have_content('Developers + Maintainers')
push = push_new_file(branch_name) @push = push_new_file(branch_name)
expect(push.output).to match(/remote: To create a merge request for protected-branch, visit/) expect(@push.output).to match(/remote: To create a merge request for protected-branch, visit/)
end end
end end
...@@ -37,11 +41,11 @@ module QA ...@@ -37,11 +41,11 @@ module QA
scenario 'user without push rights fails to push to the protected branch' do scenario 'user without push rights fails to push to the protected branch' do
create_protected_branch(allow_to_push: false) create_protected_branch(allow_to_push: false)
push = push_new_file(branch_name) @push = push_new_file(branch_name)
expect(push.output) expect(@push.output)
.to match(/remote\: GitLab\: You are not allowed to push code to protected branches on this project/) .to match(/remote\: GitLab\: You are not allowed to push code to protected branches on this project/)
expect(push.output) expect(@push.output)
.to match(/\[remote rejected\] #{branch_name} -> #{branch_name} \(pre-receive hook declined\)/) .to match(/\[remote rejected\] #{branch_name} -> #{branch_name} \(pre-receive hook declined\)/)
end end
end end
...@@ -65,5 +69,13 @@ module QA ...@@ -65,5 +69,13 @@ module QA
resource.new_branch = false resource.new_branch = false
end end
end end
def log_push_output
if defined?(@push)
filename = File.join('tmp', "push-output-#{project.name}")
puts "Exception detected. Push output will be saved to #{filename}"
IO.binwrite(filename, @push.output)
end
end
end end
end end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册