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 authored and ydah committed Aug 8, 2024
1 parent e61bb6f commit 81529af
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,25 @@ 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']
compiler: ['g++', 'clang++']
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: ${{ matrix.compiler }}
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 @@ -11,6 +11,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 @@ -29,7 +33,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 @@ -50,7 +54,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 81529af

Please sign in to comment.