diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 315c0842a..97fe0a7f0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -196,10 +196,30 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 + - name: setup + uses: ./.github/workflows/setup + with: + haxe: ${{ inputs.haxe }} + - name: Get Haxe commit SHA + if: inputs.haxe == 'latest' + id: haxe_sha + shell: bash + working-directory: + ${{github.workspace}} + env: + GH_TOKEN: ${{ github.token }} + run: | + version=$(haxe --version) + short_sha=${version##*+} + full_sha=$(gh api repos/HaxeFoundation/haxe/commits/$short_sha --jq '.sha') + echo "Haxe version: $version" + echo "sha=$full_sha" >> "$GITHUB_OUTPUT" + echo "Commit SHA: $short_sha, Full SHA: $full_sha" - name: checkout haxe (latest) if: inputs.haxe == 'latest' uses: actions/checkout@v4 with: + ref: ${{ steps.haxe_sha.outputs.sha }} repository: HaxeFoundation/haxe path: haxe - name: checkout haxe (stable) @@ -209,10 +229,6 @@ jobs: repository: HaxeFoundation/haxe path: haxe ref: ${{ inputs.haxe }} - - name: setup - uses: ./.github/workflows/setup - with: - haxe: ${{ inputs.haxe }} - name: install haxe libs run: haxelib install compile-cpp.hxml --always # haxe 4 tests don't build with latest utest diff --git a/test/haxe/TestWeakHash.hx b/test/haxe/TestWeakHash.hx index d1db98627..385570be5 100644 --- a/test/haxe/TestWeakHash.hx +++ b/test/haxe/TestWeakHash.hx @@ -52,30 +52,54 @@ class TestWeakHash extends Test Assert.isTrue(oddFound<=2, "Too many odd values retained " + oddFound); Assert.isTrue(valid>=expect && valid, expect:Int) - { - if (inDepth<1) - checkMap(map,expect); - else - deepCheckMap(inDepth-1, map, expect); - } - - function deepClearRetained(inRecurse:Int) - { - if (inRecurse>0) - deepClearRetained(inRecurse-1); - else - retained = []; - } public function test() { - final map = createMapDeep(20,1000); + var map : WeakMap = null; + + final sema = new sys.thread.Semaphore(0); + sys.thread.Thread.create(() -> { + map = createMap(1000); + sema.release(); + }); + sema.acquire(); + + // Give the thread enough time to exit and unregister itself from the GC + Sys.sleep(1); + cpp.vm.Gc.run(true); - deepCheckMap(10,map,500); - deepClearRetained(10); + + final sema = new sys.thread.Semaphore(0); + sys.thread.Thread.create(() -> { + checkMap(map,500); + sema.release(); + }); + sema.acquire(); + + // Give the thread enough time to exit and unregister itself from the GC + Sys.sleep(1); + + final sema = new sys.thread.Semaphore(0); + sys.thread.Thread.create(() -> { + retained = []; + sema.release(); + }); + sema.acquire(); + + // Give the thread enough time to exit and unregister itself from the GC + Sys.sleep(1); + cpp.vm.Gc.run(true); - checkMap(map,0); + + final sema = new sys.thread.Semaphore(0); + sys.thread.Thread.create(() -> { + checkMap(map,0); + sema.release(); + }); + sema.acquire(); + + // Give the thread enough time to exit and unregister itself from the GC + Sys.sleep(1); Assert.pass(); }