Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ for:
# separately execute tests without -j which may crash worker with -j.
- >-
nmake -l
"TESTOPTS=-v --timeout-scale=3.0 --excludes=../test/excludes/_appveyor"
"TESTOPTS=--timeout-scale=3.0 --excludes=../test/excludes/_appveyor"
TESTS="
../test/win32ole
../test/ruby/test_bignum.rb
../test/ruby/test_syntax.rb
../test/open-uri/test_open-uri.rb
../test/rubygems/test_bundled_ca.rb
" test-all
- nmake -l test-spec MSPECOPT=-fs # not using `-j` because sometimes `mspec -j` silently dies on Windows
- nmake -l test-spec # not using `-j` because sometimes `mspec -j` silently dies on Windows
notifications:
- provider: Webhook
method: POST
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,10 @@ jobs:
:vcset
set | C:\msys64\usr\bin\sort > old.env
call %VCVARS%
nmake -f nul
set TMP=%USERPROFILE%\AppData\Local\Temp
set TEMP=%USERPROFILE%\AppData\Local\Temp
set MAKEFLAGS=l
set /a TEST_JOBS=(15 * %NUMBER_OF_PROCESSORS% / 10) > nul
set | C:\msys64\usr\bin\sort > new.env
C:\msys64\usr\bin\comm -13 old.env new.env >> %GITHUB_ENV%
Expand Down Expand Up @@ -162,7 +164,7 @@ jobs:
- run: nmake test
timeout-minutes: 5

- run: nmake test-spec MSPECOPT="-V -fspec"
- run: nmake test-spec
timeout-minutes: 10

- run: nmake test-all
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ script:
if [ -n "${TEST_ALL_OPTS_SEPARATED}" ]; then
$SETARCH make -s test-all -o exts TESTOPTS="$JOBS -v --tty=no ${TEST_ALL_OPTS_SEPARATED}" RUBYOPT="-w" || :
fi
- $SETARCH make -s test-spec MSPECOPT=-ff # not using `-j` because sometimes `mspec -j` silently dies
- $SETARCH make -s test-spec # not using `-j` because sometimes `mspec -j` silently dies
- $SETARCH make -s -o showflags leaked-globals

# We enable Travis on the specific branches or forked repositories here.
Expand Down
12 changes: 6 additions & 6 deletions doc/contributing/testing_ruby.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,28 +99,28 @@ We can run any of the make scripts [in parallel](building_ruby.md#label-Running+
make test-spec
```

To run a specific directory, we can use `MSPECOPT` to specify the directory:
To run a specific directory, we can use `SPECOPTS` to specify the directory:

```
make test-spec MSPECOPT=spec/ruby/core/array
make test-spec SPECOPTS=spec/ruby/core/array
```

To run a specific file, we can also use `MSPECOPT` to specify the file:
To run a specific file, we can also use `SPECOPTS` to specify the file:

```
make test-spec MSPECOPT=spec/ruby/core/array/any_spec.rb
make test-spec SPECOPTS=spec/ruby/core/array/any_spec.rb
```

To run a specific test, we can use the `--example` flag to match against the test name:

```
make test-spec MSPECOPT="../spec/ruby/core/array/any_spec.rb --example='is false if the array is empty'"
make test-spec SPECOPTS="../spec/ruby/core/array/any_spec.rb --example='is false if the array is empty'"
```

To run these specs with logs, we can use:

```
make test-spec MSPECOPT=-Vfs
make test-spec SPECOPTS=-Vfs
```

To run a ruby-spec file or directory with GNU make, we can use
Expand Down
8 changes: 4 additions & 4 deletions spec/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,24 +91,24 @@ To run all specs:
make test-spec
```

Extra arguments can be added via `MSPECOPT`.
Extra arguments can be added via `SPECOPTS`.
For instance, to show the help:

```bash
make test-spec MSPECOPT=-h
make test-spec SPECOPTS=-h
```

You can also run the specs in parallel, which is currently experimental.
It takes around 10s instead of 60s on a quad-core laptop.

```bash
make test-spec MSPECOPT=-j
make test-spec SPECOPTS=-j
```

To run a specific test, add its path to the command:

```bash
make test-spec MSPECOPT=spec/ruby/language/for_spec.rb
make test-spec SPECOPTS=spec/ruby/language/for_spec.rb
```

If ruby trunk is your current `ruby` in `$PATH`, you can also run `mspec` directly:
Expand Down
69 changes: 69 additions & 0 deletions spec/default.mspec
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,72 @@ end
class MSpecScript
prepend JobServer
end

require 'mspec/runner/formatters/dotted'

class DottedFormatter
prepend Module.new {
BASE = __dir__ + "/ruby/"

def initialize(out = nil)
super
if out
@columns = nil
else
columns = ENV["COLUMNS"]&.to_i
@columns = columns&.nonzero? || 80
end
@dotted = 0
@loaded = false
@count = 0
end

def register
super
MSpec.register :load, self
MSpec.register :unload, self
end

def after(*)
if @columns
if @dotted == 0
s = sprintf("%6d ", @count)
print(s)
@dotted += s.size
end
@count +=1
end
super
if @columns and (@dotted += 1) >= @columns
print "\n"
@dotted = 0
end
end

def load(*)
file = MSpec.file || MSpec.files_array.first
@loaded = true
s = "#{file.delete_prefix(BASE)}:"
print s
if @columns
if (@dotted += s.size) >= @columns
print "\n"
@dotted = 0
else
print " "
@dotted += 1
end
end
@count = 0
end

def unload
super
if @loaded
print "\n" if @dotted > 0
@dotted = 0
@loaded = nil
end
end
}
end