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
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,17 @@ jobs:
run: sudo rm /usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb

- name: Initialize CodeQL
uses: github/codeql-action/init@e296a935590eb16afc0c0108289f68c87e2a89a5 # v4.30.7
uses: github/codeql-action/init@9e907b5e64f6b83e7804b09294d44122997950d6 # v4.32.3
with:
languages: ${{ matrix.language }}
trap-caching: false
debug: true

- name: Autobuild
uses: github/codeql-action/autobuild@e296a935590eb16afc0c0108289f68c87e2a89a5 # v4.30.7
uses: github/codeql-action/autobuild@9e907b5e64f6b83e7804b09294d44122997950d6 # v4.32.3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@e296a935590eb16afc0c0108289f68c87e2a89a5 # v4.30.7
uses: github/codeql-action/analyze@9e907b5e64f6b83e7804b09294d44122997950d6 # v4.32.3
with:
category: '/language:${{ matrix.language }}'
upload: False
Expand Down Expand Up @@ -115,7 +115,7 @@ jobs:
continue-on-error: true

- name: Upload SARIF
uses: github/codeql-action/upload-sarif@e296a935590eb16afc0c0108289f68c87e2a89a5 # v4.30.7
uses: github/codeql-action/upload-sarif@9e907b5e64f6b83e7804b09294d44122997950d6 # v4.32.3
with:
sarif_file: sarif-results/${{ matrix.language }}.sarif
continue-on-error: true
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ jobs:
matrix:
include:
# Using the same setup as ZJIT jobs
- bench_opts: '--warmup=1 --bench=1 --excludes=lobsters,shipit'
- bench_opts: '--warmup=1 --bench=1 --excludes=shipit'

runs-on: ubuntu-24.04

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/zjit-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ jobs:
include:
# Test --call-threshold=2 with 2 iterations in total
- ruby_opts: '--zjit-call-threshold=2'
bench_opts: '--warmup=1 --bench=1 --excludes=lobsters,shipit'
bench_opts: '--warmup=1 --bench=1 --excludes=shipit'
configure: '--enable-zjit=dev_nodebug' # --enable-zjit=dev is too slow

runs-on: macos-14
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/zjit-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ jobs:
include:
# Test --call-threshold=2 with 2 iterations in total
- ruby_opts: '--zjit-call-threshold=2'
bench_opts: '--warmup=1 --bench=1 --excludes=lobsters,shipit'
bench_opts: '--warmup=1 --bench=1 --excludes=shipit'
configure: '--enable-zjit=dev_nodebug' # --enable-zjit=dev is too slow

runs-on: ubuntu-24.04
Expand Down
19 changes: 13 additions & 6 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ timestamp/distclean:: ext/distclean .bundle/distclean
timestamp/realclean:: ext/realclean .bundle/realclean

timestamp/clean timestamp/distclean timestamp/realclean::
$(Q)$(RM) $(TIMESTAMPDIR)/.*.time $(TIMESTAMPDIR)/$(arch)/.time
$(Q)$(RM) $(TIMESTAMPDIR)/*.time $(TIMESTAMPDIR)/.*.time $(TIMESTAMPDIR)/$(arch)/.time
$(Q)$(RMDIRS) $(TIMESTAMPDIR)/$(arch) $(TIMESTAMPDIR) 2> $(NULL) || $(NULLCMD)

clean-ext::
Expand Down Expand Up @@ -900,8 +900,8 @@ test: test-short

# Separate to skip updating encs and exts by `make -o test-precheck`
# for GNU make.
test-precheck: $(ENCSTATIC:static=lib)encs $(RUBYSPEC_CAPIEXT_BUILD) exts PHONY $(DOT_WAIT)
yes-test-all-precheck: programs $(DOT_WAIT) test-precheck
test-precheck: $(ENCSTATIC:static=lib)encs exts PHONY $(DOT_WAIT)
yes-test-all-precheck: programs $(DOT_WAIT) test-precheck yes-fake

PRECHECK_TEST_ALL = yes-test-all-precheck

Expand Down Expand Up @@ -951,7 +951,7 @@ $(RBCONFIG):
test-rubyspec: test-spec
yes-test-rubyspec: yes-test-spec

yes-test-spec-precheck: yes-test-all-precheck yes-fake
yes-test-spec-precheck: yes-test-all-precheck $(RUBYSPEC_CAPIEXT_BUILD)

test-spec: $(TEST_RUNNABLE)-test-spec
yes-test-spec: yes-test-spec-precheck
Expand Down Expand Up @@ -1561,8 +1561,11 @@ yes-install-for-test-bundled-gems: yes-update-default-gemspecs

test-bundled-gems-fetch: yes-test-bundled-gems-fetch
yes-test-bundled-gems-fetch: clone-bundled-gems-src
clone-bundled-gems-src: PHONY
clone-bundled-gems-src: PHONY $(TIMESTAMPDIR)/bundled-gems-src.time
$(TIMESTAMPDIR)/bundled-gems-src.time: $(srcdir)/gems/bundled_gems
$(Q) $(MAKEDIRS) $(@D)
$(Q) $(BASERUBY) -C $(srcdir) tool/fetch-bundled_gems.rb BUNDLED_GEMS="$(BUNDLED_GEMS)" gems/src gems/bundled_gems
$(Q) $(TOUCH) $@
no-test-bundled-gems-fetch:

test-bundled-gems-prepare: $(TEST_RUNNABLE)-test-bundled-gems-prepare
Expand Down Expand Up @@ -1596,7 +1599,7 @@ yes-test-bundled-gems-run: $(PREPARE_BUNDLED_GEMS)
no-test-bundled-gems-run: $(PREPARE_BUNDLED_GEMS)

test-bundled-gems-spec: $(TEST_RUNNABLE)-test-bundled-gems-spec
yes-test-bundled-gems-spec: yes-test-spec-precheck $(PREPARE_BUNDLED_GEMS)
yes-test-bundled-gems-spec: yes-test-all-precheck $(PREPARE_BUNDLED_GEMS)
$(ACTIONS_GROUP)
$(gnumake_recursive)$(Q) \
$(RUNRUBY) -r./$(arch)-fake -r$(tooldir)/lib/_tmpdir \
Expand Down Expand Up @@ -1635,6 +1638,8 @@ test-bundler: $(TEST_RUNNABLE)-test-bundler
yes-test-bundler: $(PREPARE_BUNDLER)
$(gnumake_recursive)$(XRUBY) \
-r./$(arch)-fake \
-r$(tooldir)/lib/_tmpdir \
-e '$$no_report_tmpdir = true' \
-I$(srcdir)/spec/bundler -I$(srcdir)/spec/lib \
-e 'Dir.chdir(ARGV.shift); load("spec/bin/rspec")' $(srcdir) \
-r spec_helper $(RSPECOPTS) spec/bundler/$(BUNDLER_SPECS)
Expand All @@ -1645,6 +1650,8 @@ test-bundler-parallel: $(TEST_RUNNABLE)-test-bundler-parallel
yes-test-bundler-parallel: $(PREPARE_BUNDLER)
$(gnumake_recursive)$(XRUBY) \
-r./$(arch)-fake \
-r$(tooldir)/lib/_tmpdir \
-e '$$no_report_tmpdir = true' \
-I$(srcdir)/spec/bundler \
-e "ruby = ENV['RUBY']" \
-e "ARGV[-1] = File.expand_path(ARGV[-1])" \
Expand Down
57 changes: 16 additions & 41 deletions complex.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,6 @@ static ID id_abs, id_arg,
#define id_quo idQuo
#define id_fdiv idFdiv

#define fun1(n) \
inline static VALUE \
f_##n(VALUE x)\
{\
return rb_funcall(x, id_##n, 0);\
}

#define fun2(n) \
inline static VALUE \
f_##n(VALUE x, VALUE y)\
{\
return rb_funcall(x, id_##n, 1, y);\
}

#define PRESERVE_SIGNEDZERO

inline static VALUE
Expand Down Expand Up @@ -276,8 +262,6 @@ f_to_f(VALUE x)
return rb_funcall(x, id_to_f, 0);
}

fun1(to_r)

inline static int
f_eqeq_p(VALUE x, VALUE y)
{
Expand All @@ -288,8 +272,18 @@ f_eqeq_p(VALUE x, VALUE y)
return (int)rb_equal(x, y);
}

fun2(expt)
fun2(fdiv)
static VALUE
f_fdiv(VALUE x, VALUE y)
{
if (RB_INTEGER_TYPE_P(x))
return rb_int_fdiv(x, y);
if (RB_FLOAT_TYPE_P(x))
return rb_float_div(x, y);
if (RB_TYPE_P(x, T_RATIONAL))
return rb_rational_fdiv(x, y);

return rb_funcallv(x, id_fdiv, 1, &y);
}

static VALUE
f_quo(VALUE x, VALUE y)
Expand Down Expand Up @@ -318,24 +312,6 @@ f_negative_p(VALUE x)

#define f_positive_p(x) (!f_negative_p(x))

inline static bool
f_zero_p(VALUE x)
{
if (RB_FLOAT_TYPE_P(x)) {
return FLOAT_ZERO_P(x);
}
else if (RB_INTEGER_TYPE_P(x)) {
return FIXNUM_ZERO_P(x);
}
else if (RB_TYPE_P(x, T_RATIONAL)) {
const VALUE num = RRATIONAL(x)->num;
return FIXNUM_ZERO_P(num);
}
return rb_equal(x, ZERO) != 0;
}

#define f_nonzero_p(x) (!f_zero_p(x))

static inline bool
always_finite_type_p(VALUE x)
{
Expand Down Expand Up @@ -1216,11 +1192,10 @@ rb_complex_pow(VALUE self, VALUE other)
if (RB_BIGNUM_TYPE_P(other))
rb_warn("in a**b, b may be too big");

r = f_abs(self);
theta = f_arg(self);
r = rb_num_pow(f_abs(self), other);
theta = f_mul(f_arg(self), other);

return f_complex_polar(CLASS_OF(self), f_expt(r, other),
f_mul(theta, other));
return f_complex_polar(CLASS_OF(self), r, theta);
}
return rb_num_coerce_bin(self, other, id_expt);
}
Expand Down Expand Up @@ -1873,7 +1848,7 @@ nucomp_to_r(VALUE self)
self);
}
}
return f_to_r(dat->real);
return rb_funcallv(dat->real, id_to_r, 0, 0);
}

/*
Expand Down
1 change: 1 addition & 0 deletions internal/numeric.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ VALUE rb_int_gt(VALUE x, VALUE y);
VALUE rb_float_gt(VALUE x, VALUE y);
VALUE rb_int_ge(VALUE x, VALUE y);
enum ruby_num_rounding_mode rb_num_get_rounding_option(VALUE opts);
VALUE rb_int_fdiv(VALUE x, VALUE y);
double rb_int_fdiv_double(VALUE x, VALUE y);
VALUE rb_int_pow(VALUE x, VALUE y);
VALUE rb_float_pow(VALUE x, VALUE y);
Expand Down
19 changes: 19 additions & 0 deletions internal/rational.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ VALUE rb_rational_plus(VALUE self, VALUE other);
VALUE rb_rational_minus(VALUE self, VALUE other);
VALUE rb_rational_mul(VALUE self, VALUE other);
VALUE rb_rational_div(VALUE self, VALUE other);
VALUE rb_rational_fdiv(VALUE self, VALUE other);
VALUE rb_lcm(VALUE x, VALUE y);
VALUE rb_rational_reciprocal(VALUE x);
VALUE rb_cstr_to_rat(const char *, int);
Expand Down Expand Up @@ -68,4 +69,22 @@ RATIONAL_SET_DEN(VALUE r, VALUE d)
RB_OBJ_WRITE(r, &RRATIONAL(r)->den, d);
}

inline static bool
f_zero_p(VALUE x)
{
if (RB_INTEGER_TYPE_P(x)) {
return FIXNUM_ZERO_P(x);
}
else if (RB_FLOAT_TYPE_P(x)) {
return FLOAT_ZERO_P(x);
}
else if (RB_TYPE_P(x, T_RATIONAL)) {
const VALUE num = RRATIONAL(x)->num;
return FIXNUM_ZERO_P(num);
}
return rb_equal(x, INT2FIX(0)) != 0;
}

#define f_nonzero_p(x) (!f_zero_p(x))

#endif /* INTERNAL_RATIONAL_H */
7 changes: 5 additions & 2 deletions lib/bundler/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,13 @@ def loaded?(plugin)
# @param [Array<String>] names of inferred source plugins that can be ignored
def save_plugins(plugins, specs, optional_plugins = [])
plugins.each do |name|
next if index.installed?(name)

spec = specs[name]

# It's possible that the `plugin` found in the Gemfile don't appear in the specs. For instance when
# calling `BUNDLE_WITHOUT=default bundle install`, the plugins will not get installed.
next if spec.nil?
next if index.installed?(name)

save_plugin(name, spec, optional_plugins.include?(name))
end
end
Expand Down
22 changes: 3 additions & 19 deletions rational.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,22 +175,6 @@ f_idiv(VALUE x, VALUE y)

#define f_expt10(x) rb_int_pow(INT2FIX(10), x)

inline static int
f_zero_p(VALUE x)
{
if (RB_INTEGER_TYPE_P(x)) {
return FIXNUM_ZERO_P(x);
}
else if (RB_TYPE_P(x, T_RATIONAL)) {
VALUE num = RRATIONAL(x)->num;

return FIXNUM_ZERO_P(num);
}
return (int)rb_equal(x, ZERO);
}

#define f_nonzero_p(x) (!f_zero_p(x))

inline static int
f_one_p(VALUE x)
{
Expand Down Expand Up @@ -970,8 +954,8 @@ rb_rational_div(VALUE self, VALUE other)
* Rational(2, 3).fdiv(0.5) #=> 1.3333333333333333
* Rational(2).fdiv(3) #=> 0.6666666666666666
*/
static VALUE
nurat_fdiv(VALUE self, VALUE other)
VALUE
rb_rational_fdiv(VALUE self, VALUE other)
{
VALUE div;
if (f_zero_p(other))
Expand Down Expand Up @@ -2774,7 +2758,7 @@ Init_Rational(void)
rb_define_method(rb_cRational, "*", rb_rational_mul, 1);
rb_define_method(rb_cRational, "/", rb_rational_div, 1);
rb_define_method(rb_cRational, "quo", rb_rational_div, 1);
rb_define_method(rb_cRational, "fdiv", nurat_fdiv, 1);
rb_define_method(rb_cRational, "fdiv", rb_rational_fdiv, 1);
rb_define_method(rb_cRational, "**", nurat_expt, 1);

rb_define_method(rb_cRational, "<=>", rb_rational_cmp, 1);
Expand Down
2 changes: 2 additions & 0 deletions spec/bundler/install/global_cache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def source2_global_cache(*segments)
end

it "shows a proper error message if a cached gem is corrupted" do
skip "This example is not working on ruby/ruby repo" if ruby_core?

source_global_cache.mkpath
FileUtils.touch(source_global_cache("myrack-1.0.0.gem"))

Expand Down
12 changes: 12 additions & 0 deletions spec/bundler/plugins/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,18 @@ def exec(command, args)
plugin_should_be_installed("foo")
end

it "respects bundler groups" do
gemfile <<-G
source 'https://gem.repo2'
plugin 'foo'
gem 'myrack', "1.0.0"
G

bundle "install", env: { "BUNDLE_WITHOUT" => "default" }

expect(out).to include("Bundle complete! 1 Gemfile dependency, 0 gems now installed.")
end

it "accepts plugin version" do
update_repo2 do
build_plugin "foo", "1.1.0"
Expand Down
14 changes: 4 additions & 10 deletions tool/fetch-bundled_gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,10 @@
system(*%W"git clone --depth=1 --no-tags #{u} #{n}") or abort
end

if r
puts "fetching #{color.notice(r)} ..."
system("git", "fetch", "origin", r, chdir: n) or abort
c = r
else
c = ["v#{v}", v].find do |c|
puts "fetching #{color.notice(c)} ..."
system("git", "fetch", "origin", "refs/tags/#{c}:refs/tags/#{c}", chdir: n)
end or abort
end
c = (r ? [r] : ["v#{v}", v]).find do |c|
puts "fetching #{n} #{color.notice(c)} ..."
system("git", "fetch", "origin", r || "refs/tags/#{c}:refs/tags/#{c}", chdir: n)
end or abort

checkout = %w"git -c advice.detachedHead=false checkout"
info = %[, r=#{color.info(r)}] if r
Expand Down
Loading