Skip to content

Commit

Permalink
Merge branch 'master' into tag-slow-specs
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Oct 30, 2019
2 parents 02aa9dc + 11a2d2c commit 11d8617
Show file tree
Hide file tree
Showing 99 changed files with 1,052 additions and 221 deletions.
29 changes: 29 additions & 0 deletions .shopify-build/gems/cacheable-gzip-timestamp.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
From 36d6772a76adeb0a55425ca9ec30908f8fe8509c Mon Sep 17 00:00:00 2001
From: Alan Wu <[email protected]>
Date: Fri, 25 Oct 2019 18:31:13 -0400
Subject: [PATCH] Set mtime to avoid fakiness

GZIP file format has a timestamp in its header, which makes it so that
making a GZIP file with the default setting is only deterministic if
done during the same second. Set mtime to 1 instead of taking the
current time in the header. 0 does not work as that indicates to zlib
to take the current time.
---
lib/cacheable.rb | 1 +
1 file changed, 1 insertion(+)

diff --git a/lib/cacheable.rb b/lib/cacheable.rb
index eed42a8..1a98639 100644
--- a/lib/cacheable.rb
+++ b/lib/cacheable.rb
@@ -32,6 +32,7 @@ module Cacheable
def self.compress(content)
io = StringIO.new
gz = Zlib::GzipWriter.new(io)
+ gz.mtime = 1
gz.write(content)
io.string
ensure
--
2.19.1

12 changes: 0 additions & 12 deletions .shopify-build/gems/cacheable.patch

This file was deleted.

2 changes: 1 addition & 1 deletion .shopify-build/gems/cacheable.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repository [email protected]:Shopify/cacheable.git

apply-patch cacheable.patch
apply-patch cacheable-gzip-timestamp.patch

bundle install
bundle exec rake
2 changes: 1 addition & 1 deletion .shopify-build/gems/minitest.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
repository [email protected]:seattlerb/minitest.git
repository-tag [email protected]:seattlerb/minitest.git v5.12.2

gem install hoe
rake test
5 changes: 5 additions & 0 deletions .shopify-build/test-gem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ repository() {
pushd "${2-repo}"
}

repository-tag() {
git clone --depth 1 --branch "${2}" "${1}" "${3-repo}"
pushd "${3-repo}"
}

full-repository() {
git clone --single-branch "${1}" "${2-repo}"
pushd "${2-repo}"
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Bug fixes:
* Arrays now report their methods to other languages for interopability (#1768).
* Installing `sassc` now works due to using the LLVM toolchain (#1753).
* Renamed `Truffle::Interop.respond_to?` to avoid conflict with Ruby's `respond_to?` (#1491).
* Warn only if `$VERBOSE` is `true` when a magic comment is ignored (#1757).
* Make C extensions use the same libssl as the one used for the openssl C extension (#1770).

Compatibility:

Expand All @@ -27,6 +29,7 @@ Compatibility:
* Include executables of default gems, needed for `rails new` in Rails 6.
* Use compilation flags similar to MRI for C extension compilation.
* Warn for `gem update --system` as it is not fully supported yet and is often not needed.
* Pass `-undefined dynamic_lookup` to the linker on macOS like MRI.

Performance:

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ to contribute to TruffleRuby.

## Contact

The best way to get in touch with us is to join us in
https://gitter.im/graalvm/truffleruby, but you can also Tweet to
[@TruffleRuby](https://twitter.com/truffleruby), or email
The best way to get in touch with us is to join the channel `#truffleruby` of the
[GraalVM Slack](https://join.slack.com/t/graalvm/shared_invite/enQtNzk0NTc5MzUyNzg5LTAwY2YyODQ4MzJjMGJjZGQzMWY2ZDA3NWI3YzEzNDRlNGQ1MTZkYzkzM2JkYjIxMTY2NGQzNjUxOGQzZGExZmU).
You can also Tweet to [@TruffleRuby](https://twitter.com/truffleruby), or email
[email protected].

Please report security vulnerabilities via the process outlined at [reporting
Expand Down
4 changes: 4 additions & 0 deletions doc/contributor/workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ To speed up compilation of bundled C extensions, it is recommended to use
See the [related documentation](https://github.com/oracle/graal/blob/master/sulong/docs/TOOLCHAIN.md#using-a-prebuilt-graalvm-as-a-bootstrapping-toolchain)
in Sulong to build and use them.

Or set `export JT_CACHE_TOOLCHAIN=true` environment variable to have the
toolchain built and used by `jt` automatically. `jt` will keep the 4 newest
built toolchains to avoid rebuilding when branches are switched.

## Running

`jt ruby` runs TruffleRuby. You can use it exactly as you'd run the MRI `ruby`
Expand Down
5 changes: 1 addition & 4 deletions doc/user/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ forked back out of JRuby after it had matured.

### Who do I ask about TruffleRuby?

The best way to get in touch with us is to join us in
https://gitter.im/graalvm/truffleruby, but you can also Tweet to
[@TruffleRuby](https://twitter.com/truffleruby), or email
[email protected].
See the Contact section in the [README](../../README.md#contact).

### How do I know if I’m using TruffleRuby?

Expand Down
4 changes: 1 addition & 3 deletions spec/mspec/lib/mspec/guards/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ def self.implementation?(*args)
case name
when :rubinius
RUBY_ENGINE.start_with?('rbx')
when :ruby, :jruby, :truffleruby, :ironruby, :macruby, :maglev, :topaz, :opal
RUBY_ENGINE.start_with?(name.to_s)
else
raise "unknown implementation #{name}"
RUBY_ENGINE.start_with?(name.to_s)
end
end
end
Expand Down
9 changes: 4 additions & 5 deletions spec/mspec/spec/guards/platform_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,10 @@
PlatformGuard.implementation?(:ruby).should == true
end

it "raises an error when passed an unrecognized name" do
stub_const 'RUBY_ENGINE', 'ruby'
lambda {
PlatformGuard.implementation?(:python)
}.should raise_error(/unknown implementation/)
it "works for an unrecognized name" do
stub_const 'RUBY_ENGINE', 'myrubyimplementation'
PlatformGuard.implementation?(:myrubyimplementation).should == true
PlatformGuard.implementation?(:other).should == false
end
end

Expand Down
7 changes: 7 additions & 0 deletions spec/ruby/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ Lint/NestedMethodDefinition:
- language/def_spec.rb
- language/fixtures/def.rb

Lint/ShadowingOuterLocalVariable:
Exclude:
- 'core/binding/local_variables_spec.rb'
- 'core/kernel/local_variables_spec.rb'
- 'language/block_spec.rb'
- 'language/proc_spec.rb'

Lint/UnreachableCode:
Exclude:
- 'core/enumerator/lazy/fixtures/classes.rb'
Expand Down
7 changes: 0 additions & 7 deletions spec/ruby/.rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,6 @@ Lint/ShadowedArgument:
Exclude:
- 'language/fixtures/super.rb'

# Offense count: 10
Lint/ShadowingOuterLocalVariable:
Exclude:
- 'core/binding/local_variables_spec.rb'
- 'language/block_spec.rb'
- 'language/proc_spec.rb'

# Offense count: 2
# Cop supports --auto-correct.
Lint/StringConversionInInterpolation:
Expand Down
48 changes: 44 additions & 4 deletions spec/ruby/core/comparable/clamp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
require_relative 'fixtures/classes'

describe 'Comparable#clamp' do
it 'raises an Argument error unless given 2 parameters' do
c = ComparableSpecs::Weird.new(0)
-> { c.clamp(c) }.should raise_error(ArgumentError)
-> { c.clamp(c, c, c) }.should raise_error(ArgumentError)
ruby_version_is ""..."2.7" do
it 'raises an Argument error unless given 2 parameters' do
c = ComparableSpecs::Weird.new(0)
-> { c.clamp(c) }.should raise_error(ArgumentError)
-> { c.clamp(c, c, c) }.should raise_error(ArgumentError)
end
end

it 'raises an Argument error unless the 2 parameters are correctly ordered' do
Expand Down Expand Up @@ -45,4 +47,42 @@

c.clamp(one, two).should equal(two)
end

ruby_version_is "2.7" do
it 'returns self if within the given range parameters' do
one = ComparableSpecs::WithOnlyCompareDefined.new(1)
two = ComparableSpecs::WithOnlyCompareDefined.new(2)
three = ComparableSpecs::WithOnlyCompareDefined.new(3)
c = ComparableSpecs::Weird.new(2)

c.clamp(one..two).should equal(c)
c.clamp(two..two).should equal(c)
c.clamp(one..three).should equal(c)
c.clamp(two..three).should equal(c)
end

it 'returns the minimum value of the range parameters if smaller than it' do
one = ComparableSpecs::WithOnlyCompareDefined.new(1)
two = ComparableSpecs::WithOnlyCompareDefined.new(2)
c = ComparableSpecs::Weird.new(0)

c.clamp(one..two).should equal(one)
end

it 'returns the maximum value of the range parameters if greater than it' do
one = ComparableSpecs::WithOnlyCompareDefined.new(1)
two = ComparableSpecs::WithOnlyCompareDefined.new(2)
c = ComparableSpecs::Weird.new(3)

c.clamp(one..two).should equal(two)
end

it 'raises an Argument error if the range parameter is exclusive' do
one = ComparableSpecs::WithOnlyCompareDefined.new(1)
two = ComparableSpecs::WithOnlyCompareDefined.new(2)
c = ComparableSpecs::Weird.new(3)

-> { c.clamp(one...two) }.should raise_error(ArgumentError)
end
end
end
10 changes: 9 additions & 1 deletion spec/ruby/core/env/assoc_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
require_relative '../../spec_helper'

describe "ENV.assoc" do
before :each do
@foo = ENV["foo"]
end

after :each do
ENV.delete("foo")
ENV["foo"] = @foo
end

it "returns an array of the key and value of the environment variable with the given key" do
Expand All @@ -20,4 +24,8 @@
k.should_receive(:to_str).and_return("foo")
ENV.assoc(k).should == ["foo", "bar"]
end

it "raises TypeError if the argument is not a String and does not respond to #to_str" do
-> { ENV.assoc(Object.new) }.should raise_error(TypeError)
end
end
2 changes: 1 addition & 1 deletion spec/ruby/core/env/clear_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
it "deletes all environment variables" do
orig = ENV.to_hash
begin
ENV.clear
ENV.clear.should equal(ENV)

# This used 'env' the helper before. That shells out to 'env' which
# itself sets up certain environment variables before it runs, because
Expand Down
37 changes: 32 additions & 5 deletions spec/ruby/core/env/delete_if_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,52 @@
require_relative '../enumerable/shared/enumeratorized'

describe "ENV.delete_if" do
before :each do
@foo = ENV["foo"]
@bar = ENV["bar"]

ENV["foo"] = "0"
ENV["bar"] = "1"
end

after :each do
ENV["foo"] = @foo
ENV["bar"] = @bar
end

it "deletes pairs if the block returns true" do
ENV["foo"] = "bar"
ENV.delete_if { |k, v| k == "foo" }
ENV.delete_if { |k, v| ["foo", "bar"].include?(k) }
ENV["foo"].should == nil
ENV["bar"].should == nil
end

it "returns ENV when block given" do
ENV.delete_if { |k, v| ["foo", "bar"].include?(k) }.should equal(ENV)
end

it "returns ENV even if nothing deleted" do
ENV.delete_if { false }.should_not == nil
ENV.delete_if { false }.should equal(ENV)
end

it "returns an Enumerator if no block given" do
ENV.delete_if.should be_an_instance_of(Enumerator)
end

it "deletes pairs through enumerator" do
ENV["foo"] = "bar"
enum = ENV.delete_if
enum.each { |k, v| k == "foo" }
enum.each { |k, v| ["foo", "bar"].include?(k) }
ENV["foo"].should == nil
ENV["bar"].should == nil
end

it "returns ENV from enumerator" do
enum = ENV.delete_if
enum.each { |k, v| ["foo", "bar"].include?(k) }.should equal(ENV)
end

it "returns ENV from enumerator even if nothing deleted" do
enum = ENV.delete_if
enum.each { false }.should equal(ENV)
end

it_behaves_like :enumeratorized_with_origin_size, :delete_if, ENV
Expand Down
14 changes: 13 additions & 1 deletion spec/ruby/core/env/delete_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
require_relative '../../spec_helper'

describe "ENV.delete" do
before :each do
@saved_foo = ENV["foo"]
end
after :each do
ENV.delete("foo")
ENV["foo"] = @saved_foo
end

it "removes the variable from the environment" do
Expand All @@ -16,9 +19,18 @@
ENV.delete("foo").should == "bar"
end

it "returns nil if the named environment variable does not exist and no block given" do
ENV.delete("foo")
ENV.delete("foo").should == nil
end

it "yields the name to the given block if the named environment variable does not exist" do
ENV.delete("foo")
ENV.delete("foo") { |name| ScratchPad.record name }
ScratchPad.recorded.should == "foo"
end

it "raises TypeError if the argument is not a String and does not respond to #to_str" do
-> { ENV.delete(Object.new) }.should raise_error(TypeError, "no implicit conversion of Object into String")
end
end
4 changes: 3 additions & 1 deletion spec/ruby/core/env/each_key_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
end

it "returns an Enumerator if called without a block" do
ENV.each_key.should be_an_instance_of(Enumerator)
enum = ENV.each_key
enum.should be_an_instance_of(Enumerator)
enum.to_a.should == ENV.keys
end

it "returns keys in the locale encoding" do
Expand Down
4 changes: 3 additions & 1 deletion spec/ruby/core/env/each_value_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
end

it "returns an Enumerator if called without a block" do
ENV.each_value.should be_an_instance_of(Enumerator)
enum = ENV.each_value
enum.should be_an_instance_of(Enumerator)
enum.to_a.should == ENV.values
end

it "uses the locale encoding" do
Expand Down
11 changes: 11 additions & 0 deletions spec/ruby/core/env/element_reference_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
ENV[@variable].frozen?.should == true
end

it "coerces a non-string name with #to_str" do
ENV[@variable] = "bar"
k = mock('key')
k.should_receive(:to_str).and_return(@variable)
ENV[k].should == "bar"
end

it "raises TypeError if the argument is not a String and does not respond to #to_str" do
-> { ENV[Object.new] }.should raise_error(TypeError, "no implicit conversion of Object into String")
end

platform_is :windows do
it "looks up values case-insensitively" do
ENV[@variable] = "bar"
Expand Down
Loading

0 comments on commit 11d8617

Please sign in to comment.