Skip to content

Commit 0401840

Browse files
committed
1 parent 32e210e commit 0401840

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

spec/mspec/lib/mspec/utils/warnings.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
require 'mspec/guards/version'
22

3-
if RUBY_ENGINE == "ruby"
3+
# Always enable deprecation warnings when running MSpec, as ruby/spec tests for them,
4+
# and like in most test frameworks, all warnings should be enabled by default (same as -w).
5+
if Object.const_defined?(:Warning) and Warning.respond_to?(:[]=)
6+
Warning[:deprecated] = true
7+
end
8+
9+
if Object.const_defined?(:Warning) and Warning.respond_to?(:warn)
410
def Warning.warn(message)
511
# Suppress any warning inside the method to prevent recursion
612
verbose = $VERBOSE

spec/mspec/tool/sync/sync-rubyspec.rb

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,16 @@ def rebase_commits(impl)
157157
end
158158
end
159159

160+
def new_commits?(impl)
161+
Dir.chdir(SOURCE_REPO) do
162+
diff = `git diff master #{impl.rebased_branch}`
163+
!diff.empty?
164+
end
165+
end
166+
160167
def test_new_specs
161168
require "yaml"
162169
Dir.chdir(SOURCE_REPO) do
163-
diff = `git diff master`
164-
abort "#{BRIGHT_YELLOW}No new commits, aborting#{RESET}" if diff.empty?
165-
166170
workflow = YAML.load_file(".github/workflows/ci.yml")
167171
job_name = MSPEC ? "test" : "specs"
168172
versions = workflow.dig("jobs", job_name, "strategy", "matrix", "ruby")
@@ -195,8 +199,8 @@ def verify_commits(impl)
195199
def fast_forward_master(impl)
196200
Dir.chdir(SOURCE_REPO) do
197201
sh "git", "checkout", "master"
198-
sh "git", "merge", "--ff-only", "#{impl.name}-rebased"
199-
sh "git", "branch", "--delete", "#{impl.name}-rebased"
202+
sh "git", "merge", "--ff-only", impl.rebased_branch
203+
sh "git", "branch", "--delete", impl.rebased_branch
200204
end
201205
end
202206

@@ -215,10 +219,15 @@ def main(impls)
215219
update_repo(impl)
216220
filter_commits(impl)
217221
rebase_commits(impl)
218-
test_new_specs
219-
verify_commits(impl)
220-
fast_forward_master(impl)
221-
check_ci
222+
if new_commits?(impl)
223+
test_new_specs
224+
verify_commits(impl)
225+
fast_forward_master(impl)
226+
check_ci
227+
else
228+
STDERR.puts "#{BRIGHT_YELLOW}No new commits#{RESET}"
229+
fast_forward_master(impl)
230+
end
222231
end
223232
end
224233

0 commit comments

Comments
 (0)