Add github workflow to run RScons tests

Fix up some macOS test cases
This commit is contained in:
Josh Holtrop 2025-06-08 16:29:58 -04:00
parent 18a2a075c1
commit 8d9f19cb34
3 changed files with 55 additions and 17 deletions

38
.github/workflows/run-tests.yml vendored Normal file
View File

@ -0,0 +1,38 @@
name: Run RScons Tests
on:
push:
branches:
- master
pull_request:
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
ruby-version: ['2.7', '3.0', '3.4']
steps:
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y gcc gdc ldc clang flex bison
- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: brew install gcc ldc flex bison
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Install dependencies
run: bundle install
- name: Run tests
run: rake all

View File

@ -3,5 +3,5 @@ env do |env|
env["CFLAGS"] += %w[-S] env["CFLAGS"] += %w[-S]
env.Object("one.ssss", "one.c", "CPPFLAGS" => ["-DONE"]) env.Object("one.ssss", "one.c", "CPPFLAGS" => ["-DONE"])
env.Object("two.sss", "two.c") env.Object("two.sss", "two.c")
env.Program("two_sources.exe", %w[one.ssss two.sss], "ASFLAGS" => env["ASFLAGS"] + %w[-x assembler]) env.Program("two_sources.exe", %w[one.ssss two.sss], "ASFLAGS" => env["ASFLAGS"] + %w[-x assembler-with-cpp])
end end

View File

@ -665,7 +665,7 @@ EOF
expect(result.stdout).to eq "" expect(result.stdout).to eq ""
end end
unless RUBY_PLATFORM =~ /mingw|msys/ unless RUBY_PLATFORM =~ /mingw|msys|darwin/
it "supports building D sources with gdc" do it "supports building D sources with gdc" do
test_dir("d") test_dir("d")
result = run_rscons result = run_rscons
@ -711,7 +711,7 @@ EOF
expect(`./hello-d.exe`.rstrip).to eq "Hello from D, value is 33!" expect(`./hello-d.exe`.rstrip).to eq "Hello from D, value is 33!"
end end
unless RUBY_PLATFORM =~ /mingw|msys/ unless RUBY_PLATFORM =~ /mingw|msys|darwin/
it "links with the D linker when object files were built from D sources" do it "links with the D linker when object files were built from D sources" do
test_dir("d") test_dir("d")
result = run_rscons(args: %w[-f link_objects.rb]) result = run_rscons(args: %w[-f link_objects.rb])
@ -761,7 +761,7 @@ EOF
result = run_rscons(args: %w[-f disassemble.rb]) result = run_rscons(args: %w[-f disassemble.rb])
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
expect(File.exist?("simple.txt")).to be_truthy expect(File.exist?("simple.txt")).to be_truthy
expect(File.read("simple.txt")).to match /Disassembly of section .text:/ expect(File.read("simple.txt")).to match /Disassembly of section/
result = run_rscons(args: %w[-f disassemble.rb]) result = run_rscons(args: %w[-f disassemble.rb])
expect(result.stderr).to eq "" expect(result.stderr).to eq ""
@ -1211,7 +1211,7 @@ EOF
%r{Compiling simple.c}, %r{Compiling simple.c},
%r{My Disassemble simple.txt}, %r{My Disassemble simple.txt},
]) ])
expect(File.read("simple.txt")).to match /Disassembly of section .text:/ expect(File.read("simple.txt")).to match /Disassembly of section/
end end
end end
@ -2024,7 +2024,7 @@ EOF
{"check_d_compiler.rb" => "when no arguments are given", {"check_d_compiler.rb" => "when no arguments are given",
"check_d_compiler_find_first.rb" => "when arguments are given"}.each_pair do |rsconscript, desc| "check_d_compiler_find_first.rb" => "when arguments are given"}.each_pair do |rsconscript, desc|
context desc do context desc do
unless RUBY_PLATFORM =~ /mingw|msys/ unless RUBY_PLATFORM =~ /mingw|msys|darwin/
it "finds the first listed D compiler" do it "finds the first listed D compiler" do
test_dir "configure" test_dir "configure"
result = run_rscons(args: %W[-f #{rsconscript} configure]) result = run_rscons(args: %W[-f #{rsconscript} configure])
@ -2056,6 +2056,7 @@ EOF
end end
end end
unless RUBY_PLATFORM =~ /mingw|msys|darwin/
it "respects use flag" do it "respects use flag" do
test_dir "configure" test_dir "configure"
result = run_rscons(args: %w[-f check_d_compiler_use.rb -v]) result = run_rscons(args: %w[-f check_d_compiler_use.rb -v])
@ -2067,7 +2068,6 @@ EOF
expect(result.stdout).to_not match %r{\bgdc .*/t2/} expect(result.stdout).to_not match %r{\bgdc .*/t2/}
end end
unless RUBY_PLATFORM =~ /mingw|msys/
it "successfully tests a compiler with an unknown name that uses gdc-compatible options" do it "successfully tests a compiler with an unknown name that uses gdc-compatible options" do
test_dir "configure" test_dir "configure"
create_exe "mycompiler", %[exec gdc "$@"] create_exe "mycompiler", %[exec gdc "$@"]