Skip to content

Commit

Permalink
Add CI env for C++
Browse files Browse the repository at this point in the history
This is a follow up of ruby#443
  • Loading branch information
yui-knk committed Jun 18, 2024
1 parent bc2f0b4 commit 16a77f7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,24 @@ jobs:
- run: flex --help
- run: bundle install
- run: bundle exec rspec
test-cpp:
needs: ruby-versions
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
ruby: ['head']
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: flex --help
- run: bundle install
- run: bundle exec rspec
env:
COMPILER: 'c++'
test-memory:
runs-on: ubuntu-20.04
strategy:
Expand Down
8 changes: 6 additions & 2 deletions spec/lrama/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ def exec_command(command)
raise "#{command} failed." unless $?.success?
end

def compiler
ENV['COMPILER'] || "gcc"
end

def test_parser(parser_name, input, expected, expect_success: true, lrama_command_args: [], debug: false)
tmpdir = Dir.tmpdir
grammar_file_path = fixture_path("integration/#{parser_name}.y")
Expand All @@ -27,7 +31,7 @@ def test_parser(parser_name, input, expected, expect_success: true, lrama_comman

Lrama::Command.new.run(%W[-H#{parser_h_path} -o#{parser_c_path}] + lrama_command_args + %W[#{grammar_file_path}])
exec_command("flex --header-file=#{lexer_h_path} -o #{lexer_c_path} #{lexer_file_path}")
exec_command("gcc -Wall -ggdb3 -I#{tmpdir} #{parser_c_path} #{lexer_c_path} -o #{obj_path}")
exec_command("#{compiler} -Wall -ggdb3 -I#{tmpdir} #{parser_c_path} #{lexer_c_path} -o #{obj_path}")

out = err = status = nil

Expand All @@ -48,7 +52,7 @@ def test_parser(parser_name, input, expected, expect_success: true, lrama_comman

def generate_object(grammar_file_path, c_path, obj_path, command_args: [])
Lrama::Command.new.run(%W[-d -o #{c_path}] + command_args + %W[#{grammar_file_path}])
exec_command("gcc -Wall #{c_path} -o #{obj_path}")
exec_command("#{compiler} -Wall #{c_path} -o #{obj_path}")
end
end

Expand Down

0 comments on commit 16a77f7

Please sign in to comment.