Skip to content

Commit

Permalink
Disable tests while I seek a cleaner solution
Browse files Browse the repository at this point in the history
  • Loading branch information
haxiomic committed Sep 27, 2021
1 parent d530316 commit 631cb58
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 76 deletions.
3 changes: 3 additions & 0 deletions test/unit/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ int main(void) {
// can we pass NULL for an object?
HaxeLib_checkNull(NULL, 0);

/*
Disabled tests until we can have a cleaner solution
for (int i = 0; i < 100; i++) { // run many times to try to catch GC issues
// test returning Array<Int>
int arrayLength = 0;
Expand All @@ -181,6 +183,7 @@ int main(void) {
assert(arrayLength == 3);
logf("array char* (%d) [%s, %s, %s]", arrayLength, array[0], array[1], array[2]);
}
*/

// sleep one second and verify the haxe thread event loop continued to run
log("sleeping 1s to let the haxe thread event loop run");
Expand Down
4 changes: 0 additions & 4 deletions test/unit/haxe-bin/HaxeLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,6 @@ extern "C" {

MessagePayload HaxeLib_externStruct(MessagePayload v, MessagePayload* vStar);

int* HaxeLib_getHaxeArray(int* length);

int64_t* HaxeLib_getHaxeArrayStr(int* length);

/**
* Test the GC behavior, runs on haxe main thread
*/
Expand Down
72 changes: 0 additions & 72 deletions test/unit/haxe-bin/src/__HaxeCBridgeBindings__.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,78 +548,6 @@ MessagePayload HaxeLib_externStruct(MessagePayload a0, MessagePayload* a1) {
return data.ret;
}

HXCPP_EXTERN_CLASS_ATTRIBUTES
int* HaxeLib_getHaxeArray(int* a0) {
if (HaxeCBridgeInternal::isHaxeMainThread()) {
return test::HxPublicApi_obj::getHaxeArray(a0);
}
struct Data {
struct {int* a0;} args;
HxSemaphore lock;
int* ret;
};
struct Callback {
static void run(void* p) {
// executed within the haxe main thread
Data* data = (Data*) p;
try {
data->ret = test::HxPublicApi_obj::getHaxeArray(data->args.a0);
data->lock.Set();
} catch(Dynamic runtimeException) {
data->lock.Set();
throw runtimeException;
}
}
};

#ifdef HXCPP_DEBUG
assert(HaxeCBridgeInternal::threadRunning && "haxe thread not running, use HaxeLib_initializeHaxeThread() to activate the haxe thread");
#endif

Data data = { {a0} };

// queue a callback to execute getHaxeArray() on the main thread and wait until execution completes
HaxeCBridgeInternal::runInMainThread(Callback::run, &data);
data.lock.Wait();
return data.ret;
}

HXCPP_EXTERN_CLASS_ATTRIBUTES
int64_t* HaxeLib_getHaxeArrayStr(int* a0) {
if (HaxeCBridgeInternal::isHaxeMainThread()) {
return test::HxPublicApi_obj::getHaxeArrayStr(a0);
}
struct Data {
struct {int* a0;} args;
HxSemaphore lock;
int64_t* ret;
};
struct Callback {
static void run(void* p) {
// executed within the haxe main thread
Data* data = (Data*) p;
try {
data->ret = test::HxPublicApi_obj::getHaxeArrayStr(data->args.a0);
data->lock.Set();
} catch(Dynamic runtimeException) {
data->lock.Set();
throw runtimeException;
}
}
};

#ifdef HXCPP_DEBUG
assert(HaxeCBridgeInternal::threadRunning && "haxe thread not running, use HaxeLib_initializeHaxeThread() to activate the haxe thread");
#endif

Data data = { {a0} };

// queue a callback to execute getHaxeArrayStr() on the main thread and wait until execution completes
HaxeCBridgeInternal::runInMainThread(Callback::run, &data);
data.lock.Wait();
return data.ret;
}

HXCPP_EXTERN_CLASS_ATTRIBUTES
void HaxeLib_allocateABunchOfData() {
if (HaxeCBridgeInternal::isHaxeMainThread()) {
Expand Down
2 changes: 2 additions & 0 deletions test/unit/src/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ class PublicCApi {
return v;
}

/*
static public function getHaxeArray(length: Star<Int>) {
var array = [1,2,3,4,5];
HaxeCBridge.retainHaxeObject(array); // @! this isn't ideal, retain should happen automatically
Expand All @@ -229,6 +230,7 @@ class PublicCApi {
return cpp.Pointer.ofArray(nativeArray);
}
*/

/** Test the GC behavior, runs on haxe main thread **/
static public function allocateABunchOfData(): Void {
Expand Down

0 comments on commit 631cb58

Please sign in to comment.