diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 26a9ae40..6e2f830a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -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: diff --git a/spec/lrama/integration_spec.rb b/spec/lrama/integration_spec.rb index f10cabe2..cbe2a0df 100644 --- a/spec/lrama/integration_spec.rb +++ b/spec/lrama/integration_spec.rb @@ -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") @@ -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 @@ -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