diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index e3efaef5c1e7..5e3ed21dd360 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -67,7 +67,7 @@ jobs: - name: Test run: bin/ci build - x86_64-gnu-test-preview_mt: + x86_64-gnu-test-execution-context-parallel: env: ARCH: x86_64 ARCH_CMD: linux64 @@ -88,7 +88,30 @@ jobs: run: bin/ci with_build_env 'make crystal' - name: Test - run: bin/ci with_build_env 'CRYSTAL_WORKERS=4 make std_spec threads=1 FLAGS="-D preview_mt"' + run: bin/ci with_build_env 'CRYSTAL_WORKERS=4 make std_spec threads=1 FLAGS="-Dexecution_context -Dpreview_mt"' + + x86_64-gnu-test-execution-context-concurrent: + env: + ARCH: x86_64 + ARCH_CMD: linux64 + runs-on: ubuntu-latest + steps: + - name: Download Crystal source + uses: actions/checkout@v5 + with: + persist-credentials: false + + - name: Prepare System + run: bin/ci prepare_system + + - name: Prepare Build + run: bin/ci prepare_build + + - name: Make Crystal + run: bin/ci with_build_env 'make crystal' + + - name: Test + run: bin/ci with_build_env 'CRYSTAL_WORKERS=1 make std_spec threads=1 FLAGS="-Dexecution_context -Dpreview_mt"' check_format: env: diff --git a/src/spec.cr b/src/spec.cr index adb806b4c841..b643cd3e4b56 100644 --- a/src/spec.cr +++ b/src/spec.cr @@ -130,6 +130,12 @@ module Spec Process.on_terminate { abort! } {% end %} + {% if Fiber.has_constant?(:ExecutionContext) && Fiber::ExecutionContext.class.has_method?(:current) %} + count = ENV["CRYSTAL_WORKERS"]?.try(&.to_i?) || 1 + # FIXME: ExecutionContext.current should return ExecutionContext::Parallel + Fiber::ExecutionContext.current.as(Fiber::ExecutionContext::Parallel).resize(count) + {% end %} + run end end