Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
62 changes: 43 additions & 19 deletions test/haxe/TestWeakHash.hx
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,54 @@ class TestWeakHash extends Test
Assert.isTrue(oddFound<=2, "Too many odd values retained " + oddFound);
Assert.isTrue(valid>=expect && valid<expect+2, "WeakHash invalid range "+ expect + "..." + valid + "..." + (expect+2));
}
function deepCheckMap(inDepth:Int, map:WeakMap<WeakObjectData,Int>, 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<WeakObjectData,Int> = 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();
}
Expand Down
Loading