Skip to content

Commit

Permalink
Merge pull request #211 from eregon/truffleruby
Browse files Browse the repository at this point in the history
Fixes for TruffleRuby and add TruffleRuby in CI
  • Loading branch information
casperisfine authored Jan 22, 2024
2 parents 45f2952 + 6101e41 commit 28f31d0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
33 changes: 17 additions & 16 deletions .github/workflows/liquid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,34 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
entry:
include:
- { ruby: '2.7', allowed-failure: false }
- { ruby: '3.0', allowed-failure: false }
- { ruby: '3.1', allowed-failure: false }
- { ruby: ruby-head, allowed-failure: true }
name: test (${{ matrix.entry.ruby }})
- { ruby: truffleruby-head, allowed-failure: true }
name: test (${{ matrix.ruby }})
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.entry.ruby }}
- uses: actions/cache@v1
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('Gemfile') }}
restore-keys: ${{ runner.os }}-gems-
- run: bundle install --jobs=3 --retry=3 --path=vendor/bundle
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- run: bundle exec rake
continue-on-error: ${{ matrix.entry.allowed-failure }}
continue-on-error: ${{ matrix.allowed-failure }}
env:
LIQUID_C_PEDANTIC: 'true'
if: matrix.ruby != 'truffleruby-head'

- run: bundle exec rake test:unit
continue-on-error: ${{ matrix.allowed-failure }}
env:
LIQUID_C_PEDANTIC: 'true'
if: matrix.ruby == 'truffleruby-head'

- run: bundle exec rubocop
if: matrix.ruby != 'truffleruby-head'

valgrind:
runs-on: ubuntu-latest
Expand All @@ -35,11 +41,6 @@ jobs:
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
bundler-cache: true
- run: sudo apt-get install -y valgrind
- uses: actions/cache@v1
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('Gemfile') }}
restore-keys: ${{ runner.os }}-gems-
- run: bundle install --jobs=3 --retry=3 --path=vendor/bundle
- run: bundle exec rake test:valgrind
2 changes: 1 addition & 1 deletion ext/liquid_c/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ inline static VALUE value_to_liquid_and_set_context(VALUE value, VALUE context_t
if (RB_SPECIAL_CONST_P(value))
return value;

VALUE klass = RBASIC(value)->klass;
VALUE klass = RBASIC_CLASS(value);

// More basic types having #to_liquid of self and no #context=
if (klass == rb_cString || klass == rb_cArray || klass == rb_cHash)
Expand Down
4 changes: 1 addition & 3 deletions ext/liquid_c/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
$CFLAGS << " -DNDEBUG"
end

if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.0") # added in 2.7
$CFLAGS << " -DHAVE_RB_HASH_BULK_INSERT"
end
have_func "rb_hash_bulk_insert"

$warnflags&.gsub!(/-Wdeclaration-after-statement/, "")
create_makefile("liquid_c")
2 changes: 2 additions & 0 deletions test/unit/context_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def test_evaluate_works_with_variable_lookup
end

def test_evaluating_a_variable_entirely_within_c
skip("TracePoint :call not yet supported") if RUBY_ENGINE == "truffleruby"

context = Liquid::Context.new({ "var" => 42 })
lookup = Liquid::C::Expression.strict_parse("var")
context.evaluate(lookup) # memoize vm_internal_new calls
Expand Down

0 comments on commit 28f31d0

Please sign in to comment.