go2hx icon indicating copy to clipboard operation
go2hx copied to clipboard

Generate the test code and a test entry point for all imported packages

Open elliott5 opened this issue 3 years ago • 2 comments

The go2hx compiler should generate the test code and a test entry point (if *_test.go files exist) for all imported packages, both for documentation purposes and testing.

Go2hx users should be able to run the "go test" code of imported Go packages themselves, to satisfy themselves that the package works on their intended target.

elliott5 avatar Sep 03 '22 16:09 elliott5

I agree this would be a really nice QOL addition. Perhaps whenever a library is invoked it is compiled with the test flag active? In order to generate the packages? The only potential issue I see with this is generating multiple main entry points and needing to sort out the test ones?

Let me know what you think @elliott5 :)

PXshadow avatar Sep 03 '22 21:09 PXshadow

Compiling all Go packages with the test flag active sounds like a great way ahead @PXshadow.

There are already multiple entry-points inside the stdgo modules directory tree, one for each of the Go package tests ... and that seems to work fine, so I don't see it as a problem for all Go packages.

elliott5 avatar Sep 04 '22 03:09 elliott5

I think we reached a consensus later that setting the -test flag activate by default was a bad idea as it assumes user intention, which we don't want and can get in the way of users.

I think the best method to help users know what to expect before using a library is having the go2hx compiler look through the std imports and listing what ones are not passing of a library. Let me know if that makes sense to you @elliott5 .

PXshadow avatar Jan 18 '23 15:01 PXshadow

Yes, that makes sense in the light of our recent discussion @PXshadow .

elliott5 avatar Jan 21 '23 07:01 elliott5

Wonderful, it's in progress I'll close this.

PXshadow avatar Jan 21 '23 10:01 PXshadow