Skip to content

Commit

Permalink
Split std_specs in 32 bits ci
Browse files Browse the repository at this point in the history
  • Loading branch information
bcardiff committed Aug 9, 2019
1 parent 080c8b8 commit 7109a00
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
23 changes: 21 additions & 2 deletions bin/ci
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,27 @@ build() {

case $ARCH in
i386)
with_build_env 'make crystal std_spec threads=1'
with_build_env 'CRYSTAL_SPEC_COMPILER_THREADS=1 make compiler_spec docs threads=1'
with_build_env 'make crystal threads=1'
with_build_env 'SPEC_SPLIT="0%4" make std_spec threads=1'
with_build_env 'SPEC_SPLIT="1%4" make std_spec threads=1'
with_build_env 'SPEC_SPLIT="2%4" make std_spec threads=1'
with_build_env 'SPEC_SPLIT="3%4" make std_spec threads=1'
with_build_env 'CRYSTAL_SPEC_COMPILER_THREADS=1 SPEC_SPLIT="0%16" make compiler_spec threads=1'
with_build_env 'CRYSTAL_SPEC_COMPILER_THREADS=1 SPEC_SPLIT="1%16" make compiler_spec threads=1'
with_build_env 'CRYSTAL_SPEC_COMPILER_THREADS=1 SPEC_SPLIT="2%16" make compiler_spec threads=1'
with_build_env 'CRYSTAL_SPEC_COMPILER_THREADS=1 SPEC_SPLIT="3%16" make compiler_spec threads=1'
with_build_env 'CRYSTAL_SPEC_COMPILER_THREADS=1 SPEC_SPLIT="4%16" make compiler_spec threads=1'
with_build_env 'CRYSTAL_SPEC_COMPILER_THREADS=1 SPEC_SPLIT="5%16" make compiler_spec threads=1'
with_build_env 'CRYSTAL_SPEC_COMPILER_THREADS=1 SPEC_SPLIT="6%16" make compiler_spec threads=1'
with_build_env 'CRYSTAL_SPEC_COMPILER_THREADS=1 SPEC_SPLIT="7%16" make compiler_spec threads=1'
with_build_env 'CRYSTAL_SPEC_COMPILER_THREADS=1 SPEC_SPLIT="8%16" make compiler_spec threads=1'
with_build_env 'CRYSTAL_SPEC_COMPILER_THREADS=1 SPEC_SPLIT="9%16" make compiler_spec threads=1'
with_build_env 'CRYSTAL_SPEC_COMPILER_THREADS=1 SPEC_SPLIT="10%16" make compiler_spec threads=1'
with_build_env 'CRYSTAL_SPEC_COMPILER_THREADS=1 SPEC_SPLIT="11%16" make compiler_spec threads=1'
with_build_env 'CRYSTAL_SPEC_COMPILER_THREADS=1 SPEC_SPLIT="12%16" make compiler_spec threads=1'
with_build_env 'CRYSTAL_SPEC_COMPILER_THREADS=1 SPEC_SPLIT="13%16" make compiler_spec threads=1'
with_build_env 'CRYSTAL_SPEC_COMPILER_THREADS=1 SPEC_SPLIT="14%16" make compiler_spec threads=1'
with_build_env 'CRYSTAL_SPEC_COMPILER_THREADS=1 SPEC_SPLIT="15%16" make compiler_spec threads=1'
with_build_env 'make docs threads=1'
;;
*)
Expand Down
2 changes: 2 additions & 0 deletions src/spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ if ENV["SPEC_VERBOSE"]? == "1"
Spec.override_default_formatter(Spec::VerboseFormatter.new)
end

Spec.add_split_filter ENV["SPEC_SPLIT"]?

{% unless flag?(:win32) %}
# TODO(windows): re-enable this once Signal is ported
Signal::INT.trap { Spec.abort! }
Expand Down
24 changes: 24 additions & 0 deletions src/spec/dsl.cr
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,30 @@ module Spec
lines << line
end

@@split_filter : NamedTuple(remainder: Int32, quotient: Int32)? = nil

def self.add_split_filter(filter)
if filter
r, m = filter.split('%').map &.to_i
@@split_filter = {remainder: r, quotient: m}
else
@@split_filter = nil
end
end

@@spec_counter = -1

def self.split_filter_matches
split_filter = @@split_filter

if split_filter
@@spec_counter += 1
@@spec_counter % split_filter[:quotient] == split_filter[:remainder]
else
true
end
end

# :nodoc:
def self.matches?(description, file, line, end_line = line)
spec_pattern = @@pattern
Expand Down
1 change: 1 addition & 0 deletions src/spec/methods.cr
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module Spec::Methods
def it(description = "assert", file = __FILE__, line = __LINE__, end_line = __END_LINE__, &block)
description = description.to_s
Spec::RootContext.check_nesting_spec(file, line) do
return unless Spec.split_filter_matches
return unless Spec.matches?(description, file, line, end_line)

Spec.formatters.each(&.before_example(description))
Expand Down

0 comments on commit 7109a00

Please sign in to comment.