NordSecurity / uniffi-bindgen-go

Uniffi bindings generator for Golang
Mozilla Public License 2.0
65 stars 18 forks source link

Fail to build tests #3

Closed dangeross closed 1 year ago

dangeross commented 1 year ago

This is awesome, so first of all thanks for your time,

I have an issue running the binding tests. I ran the following:

$ ./build.sh
$ ./test_bindings.sh

Most bindings build except the callbacks and fixture_callbacks examples, giving the result:

# github.com/NordSecurity/uniffi-bindgen-go/binding_tests/generated/uniffi/callbacks
generated/uniffi/callbacks/callbacks.go:506:14: cannot use FfiConverterTypeCallAnswererINSTANCE.lower(answerer) (value of type _Ctype_ulong) as type _Ctype_ulonglong in variable declaration
# github.com/NordSecurity/uniffi-bindgen-go/binding_tests/generated/uniffi/fixture_callbacks
generated/uniffi/fixture_callbacks/fixture_callbacks.go:648:14: cannot use FfiConverterTypeForeignGettersINSTANCE.lower(callback) (value of type _Ctype_ulong) as type _Ctype_ulonglong in variable declaration
generated/uniffi/fixture_callbacks/fixture_callbacks.go:664:14: cannot use FfiConverterTypeForeignGettersINSTANCE.lower(callback) (value of type _Ctype_ulong) as type _Ctype_ulonglong in variable declaration
generated/uniffi/fixture_callbacks/fixture_callbacks.go:680:14: cannot use FfiConverterTypeForeignGettersINSTANCE.lower(callback) (value of type _Ctype_ulong) as type _Ctype_ulonglong in variable declaration
generated/uniffi/fixture_callbacks/fixture_callbacks.go:696:14: cannot use FfiConverterTypeForeignGettersINSTANCE.lower(callback) (value of type _Ctype_ulong) as type _Ctype_ulonglong in variable declaration
generated/uniffi/fixture_callbacks/fixture_callbacks.go:774:55: cannot use FfiConverterTypeStoredForeignStringifierINSTANCE.lower(callback) (value of type _Ctype_ulong) as type _Ctype_ulonglong in variable declaration
FAIL    github.com/NordSecurity/uniffi-bindgen-go/binding_tests [build failed]
Savolro commented 1 year ago

Hi and thank you for your feedback! I am unable to reproduce this. Could you please post the output of

cargo version
go version

? Also, could you please try to execute the commands via docker with:

./docker_build.sh
./docker_test_bindings.sh

?

dangeross commented 1 year ago

cargo 1.71.0-nightly (26b73d15a 2023-05-09)

go version go1.19.9 darwin/amd64

Will test docker now

dangeross commented 1 year ago

The docker commands seem to work fine:

+ bindings 3rd-party/uniffi-rs/examples/arithmetic/src/arithmetic.udl
+ target/debug/uniffi-bindgen-go 3rd-party/uniffi-rs/examples/arithmetic/src/arithmetic.udl --out-dir /mounted_workdir/binding_tests/generated --config=uniffi-test-fixtures.toml
+ bindings 3rd-party/uniffi-rs/examples/callbacks/src/callbacks.udl
+ target/debug/uniffi-bindgen-go 3rd-party/uniffi-rs/examples/callbacks/src/callbacks.udl --out-dir /mounted_workdir/binding_tests/generated --config=uniffi-test-fixtures.toml
+ bindings 3rd-party/uniffi-rs/examples/custom-types/src/custom-types.udl
+ target/debug/uniffi-bindgen-go 3rd-party/uniffi-rs/examples/custom-types/src/custom-types.udl --out-dir /mounted_workdir/binding_tests/generated --config=uniffi-test-fixtures.toml
+ bindings 3rd-party/uniffi-rs/examples/geometry/src/geometry.udl
+ target/debug/uniffi-bindgen-go 3rd-party/uniffi-rs/examples/geometry/src/geometry.udl --out-dir /mounted_workdir/binding_tests/generated --config=uniffi-test-fixtures.toml
+ bindings 3rd-party/uniffi-rs/examples/rondpoint/src/rondpoint.udl
+ target/debug/uniffi-bindgen-go 3rd-party/uniffi-rs/examples/rondpoint/src/rondpoint.udl --out-dir /mounted_workdir/binding_tests/generated --config=uniffi-test-fixtures.toml
+ bindings 3rd-party/uniffi-rs/examples/sprites/src/sprites.udl
+ target/debug/uniffi-bindgen-go 3rd-party/uniffi-rs/examples/sprites/src/sprites.udl --out-dir /mounted_workdir/binding_tests/generated --config=uniffi-test-fixtures.toml
+ bindings 3rd-party/uniffi-rs/examples/todolist/src/todolist.udl
+ target/debug/uniffi-bindgen-go 3rd-party/uniffi-rs/examples/todolist/src/todolist.udl --out-dir /mounted_workdir/binding_tests/generated --config=uniffi-test-fixtures.toml
+ bindings 3rd-party/uniffi-rs/fixtures/callbacks/src/callbacks.udl
+ target/debug/uniffi-bindgen-go 3rd-party/uniffi-rs/fixtures/callbacks/src/callbacks.udl --out-dir /mounted_workdir/binding_tests/generated --config=uniffi-test-fixtures.toml
+ bindings 3rd-party/uniffi-rs/fixtures/coverall/src/coverall.udl
+ target/debug/uniffi-bindgen-go 3rd-party/uniffi-rs/fixtures/coverall/src/coverall.udl --out-dir /mounted_workdir/binding_tests/generated --config=uniffi-test-fixtures.toml
+ bindings 3rd-party/uniffi-rs/fixtures/uniffi-fixture-time/src/chronological.udl
+ target/debug/uniffi-bindgen-go 3rd-party/uniffi-rs/fixtures/uniffi-fixture-time/src/chronological.udl --out-dir /mounted_workdir/binding_tests/generated --config=uniffi-test-fixtures.toml
+ bindings fixtures/destroy/src/destroy.udl
+ target/debug/uniffi-bindgen-go fixtures/destroy/src/destroy.udl --out-dir /mounted_workdir/binding_tests/generated --config=uniffi-test-fixtures.toml
+ bindings fixtures/errors/src/errors.udl
+ target/debug/uniffi-bindgen-go fixtures/errors/src/errors.udl --out-dir /mounted_workdir/binding_tests/generated --config=uniffi-test-fixtures.toml
+ bindings fixtures/objects/src/objects.udl
+ target/debug/uniffi-bindgen-go fixtures/objects/src/objects.udl --out-dir /mounted_workdir/binding_tests/generated --config=uniffi-test-fixtures.toml
+ pushd /mounted_workdir/binding_tests/generated/..
/mounted_workdir/binding_tests /mounted_workdir
+ LD_LIBRARY_PATH=:/mounted_workdir/target/debug
+ CGO_LDFLAGS='-luniffi_fixtures -L/mounted_workdir/target/debug -lm -ldl'
+ CGO_ENABLED=1
+ go test -v
=== RUN   TestArithmetic
--- PASS: TestArithmetic (0.00s)
=== RUN   TestCallbackWorks
--- PASS: TestCallbackWorks (0.00s)
=== RUN   TestCallbackRegistrationIsNotAffectedByGC
--- PASS: TestCallbackRegistrationIsNotAffectedByGC (0.00s)
=== RUN   TestCallbackReferenceIsDropped
--- PASS: TestCallbackReferenceIsDropped (0.10s)
=== RUN   TestTimestampMinMax
--- PASS: TestTimestampMinMax (0.00s)
=== RUN   TestDurationMax
--- PASS: TestDurationMax (0.00s)
=== RUN   TestChronologicalWorks
--- PASS: TestChronologicalWorks (0.00s)
=== RUN   TestPreEpochTimestampsSerializesCorrectly
--- PASS: TestPreEpochTimestampsSerializesCorrectly (0.00s)
=== RUN   TestTimeWorksLikeRustSystemTime
--- PASS: TestTimeWorksLikeRustSystemTime (0.00s)
=== RUN   TestTimeAndDurationOptionals
--- PASS: TestTimeAndDurationOptionals (0.00s)
=== RUN   TestCoverall
--- PASS: TestCoverall (0.00s)
=== RUN   TestCoverallArcs
thread '<unnamed>' panicked at 'expected panic: with an arc!', 3rd-party/uniffi-rs/fixtures/coverall/src/lib.rs:231:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at 'Expected panic in a fallible function!', 3rd-party/uniffi-rs/fixtures/coverall/src/lib.rs:169:9
--- PASS: TestCoverallArcs (0.01s)
=== RUN   TestCoverallReturnObjects
--- PASS: TestCoverallReturnObjects (0.00s)
=== RUN   TestCoverallSimpleErrors
thread '<unnamed>' panicked at 'oops', 3rd-party/uniffi-rs/fixtures/coverall/src/lib.rs:211:9
--- PASS: TestCoverallSimpleErrors (0.00s)
=== RUN   TestCoverallComplexErrors
thread '<unnamed>' panicked at 'Invalid input', 3rd-party/uniffi-rs/fixtures/coverall/src/lib.rs:206:18
--- PASS: TestCoverallComplexErrors (0.00s)
=== RUN   TestCoverallInterfacesInDicts
--- PASS: TestCoverallInterfacesInDicts (0.00s)
=== RUN   TestCoverallMultiThreadedCallsWork
--- PASS: TestCoverallMultiThreadedCallsWork (0.01s)
=== RUN   TestCustomTypes
--- PASS: TestCustomTypes (0.00s)
=== RUN   TestDestroyObject
--- PASS: TestDestroyObject (0.00s)
=== RUN   TestDestroyRecord
--- PASS: TestDestroyRecord (0.00s)
=== RUN   TestDestroyMap
--- PASS: TestDestroyMap (0.00s)
=== RUN   TestDestroySequence
--- PASS: TestDestroySequence (0.00s)
=== RUN   TestDestroyEnum
--- PASS: TestDestroyEnum (0.00s)
=== RUN   TestReturnErrorWithVoid
--- PASS: TestReturnErrorWithVoid (0.00s)
=== RUN   TestNoReturnErrorWithVoid
--- PASS: TestNoReturnErrorWithVoid (0.00s)
=== RUN   TestReturnErrorWithValue
--- PASS: TestReturnErrorWithValue (0.00s)
=== RUN   TestNoReturnErrorWithValue
--- PASS: TestNoReturnErrorWithValue (0.00s)
=== RUN   TestFlatErrorIs
--- PASS: TestFlatErrorIs (0.00s)
=== RUN   TestFlatErrorAs
--- PASS: TestFlatErrorAs (0.00s)
=== RUN   TestComplexErrorMessage
--- PASS: TestComplexErrorMessage (0.00s)
=== RUN   TestComplexErrorIs
--- PASS: TestComplexErrorIs (0.00s)
=== RUN   TestComplexErrorAs
--- PASS: TestComplexErrorAs (0.00s)
=== RUN   TestComplexErrorAsBase
--- PASS: TestComplexErrorAsBase (0.00s)
=== RUN   TestRustGetters_GetBool
=== RUN   TestRustGetters_GetBool/true
=== RUN   TestRustGetters_GetBool/false
=== RUN   TestRustGetters_GetBool/error_1
=== RUN   TestRustGetters_GetBool/error_2
--- PASS: TestRustGetters_GetBool (0.00s)
    --- PASS: TestRustGetters_GetBool/true (0.00s)
    --- PASS: TestRustGetters_GetBool/false (0.00s)
    --- PASS: TestRustGetters_GetBool/error_1 (0.00s)
    --- PASS: TestRustGetters_GetBool/error_2 (0.00s)
=== RUN   TestRustGetters_GetString
=== RUN   TestRustGetters_GetString/Case_1
=== RUN   TestRustGetters_GetString/Case_2
=== RUN   TestRustGetters_GetString/error
--- PASS: TestRustGetters_GetString (0.00s)
    --- PASS: TestRustGetters_GetString/Case_1 (0.00s)
    --- PASS: TestRustGetters_GetString/Case_2 (0.00s)
    --- PASS: TestRustGetters_GetString/error (0.00s)
=== RUN   TestRustGetters_GetOption
=== RUN   TestRustGetters_GetOption/happy_path
=== RUN   TestRustGetters_GetOption/nil_ok
--- PASS: TestRustGetters_GetOption (0.00s)
    --- PASS: TestRustGetters_GetOption/happy_path (0.00s)
    --- PASS: TestRustGetters_GetOption/nil_ok (0.00s)
=== RUN   TestRustGetters_GetOptionComplexError
--- PASS: TestRustGetters_GetOptionComplexError (0.00s)
=== RUN   TestRustGetters_GetList
=== RUN   TestRustGetters_GetList/case_1
=== RUN   TestRustGetters_GetList/case_2
=== RUN   TestRustGetters_GetList/nil
=== RUN   TestRustGetters_GetList/error
--- PASS: TestRustGetters_GetList (0.00s)
    --- PASS: TestRustGetters_GetList/case_1 (0.00s)
    --- PASS: TestRustGetters_GetList/case_2 (0.00s)
    --- PASS: TestRustGetters_GetList/nil (0.00s)
    --- PASS: TestRustGetters_GetList/error (0.00s)
=== RUN   TestRustGetters_GetStringOptionalCallback
=== RUN   TestRustGetters_GetStringOptionalCallback/case_OK
=== RUN   TestRustGetters_GetStringOptionalCallback/error
=== RUN   TestRustGetters_GetStringOptionalCallback/nil_getters_OK
=== RUN   TestRustGetters_GetStringOptionalCallback/nil_getters_flag_true_still_OK
=== RUN   TestRustGetters_GetStringOptionalCallback/invalid_error
--- PASS: TestRustGetters_GetStringOptionalCallback (0.00s)
    --- PASS: TestRustGetters_GetStringOptionalCallback/case_OK (0.00s)
    --- PASS: TestRustGetters_GetStringOptionalCallback/error (0.00s)
    --- PASS: TestRustGetters_GetStringOptionalCallback/nil_getters_OK (0.00s)
    --- PASS: TestRustGetters_GetStringOptionalCallback/nil_getters_flag_true_still_OK (0.00s)
    --- PASS: TestRustGetters_GetStringOptionalCallback/invalid_error (0.00s)
=== RUN   TestGeometry
--- PASS: TestGeometry (0.00s)
=== RUN   TestObject0
--- PASS: TestObject0 (0.00s)
=== RUN   TestObject1
--- PASS: TestObject1 (0.00s)
=== RUN   TestFallibleObject0
--- PASS: TestFallibleObject0 (0.00s)
=== RUN   TestFallibleObject1
--- PASS: TestFallibleObject1 (0.00s)
=== RUN   TestReturnObject
--- PASS: TestReturnObject (0.00s)
=== RUN   TestDoubleDestroy
--- PASS: TestDoubleDestroy (0.00s)
=== RUN   TestDestroyAcrossReferences
--- PASS: TestDestroyAcrossReferences (0.00s)
=== RUN   TestDestroyWithInFlightCalls
--- PASS: TestDestroyWithInFlightCalls (0.00s)
=== RUN   TestDestroyWithGC
--- PASS: TestDestroyWithGC (0.00s)
=== RUN   TestGcDoesNotDestroyObjectsWithInFlightCalls
--- PASS: TestGcDoesNotDestroyObjectsWithInFlightCalls (0.01s)
=== RUN   TestRondpointCopyWorks
--- PASS: TestRondpointCopyWorks (0.00s)
=== RUN   TestRondpointComparisonOperatorWorks
--- PASS: TestRondpointComparisonOperatorWorks (0.00s)
=== RUN   TestRondpointTestRoundTrip
--- PASS: TestRondpointTestRoundTrip (0.00s)
=== RUN   TestSpritesWork
--- PASS: TestSpritesWork (0.00s)
=== RUN   TestTodolistWorks
--- PASS: TestTodolistWorks (0.00s)
=== RUN   TestTodolistDefault
--- PASS: TestTodolistDefault (0.00s)
PASS
ok      github.com/NordSecurity/uniffi-bindgen-go/binding_tests 0.222s
dangeross commented 1 year ago

Here's the full output of ./test_bindings.sh:

+++ dirname ./test_bindings.sh
++ cd .
++ pwd
+ SCRIPT_DIR=/Users/rosssavage/Source/Examples/uniffi-bindgen-go
+ ROOT_DIR=/Users/rosssavage/Source/Examples/uniffi-bindgen-go
+ BINDINGS_DIR=/Users/rosssavage/Source/Examples/uniffi-bindgen-go/binding_tests/generated
+ BINARIES_DIR=/Users/rosssavage/Source/Examples/uniffi-bindgen-go/target/debug
+ rm -rf /Users/rosssavage/Source/Examples/uniffi-bindgen-go/binding_tests/generated
+ mkdir /Users/rosssavage/Source/Examples/uniffi-bindgen-go/binding_tests/generated
+ bindings 3rd-party/uniffi-rs/examples/arithmetic/src/arithmetic.udl
+ target/debug/uniffi-bindgen-go 3rd-party/uniffi-rs/examples/arithmetic/src/arithmetic.udl --out-dir /Users/rosssavage/Source/Examples/uniffi-bindgen-go/binding_tests/generated --config=uniffi-test-fixtures.toml
+ bindings 3rd-party/uniffi-rs/examples/callbacks/src/callbacks.udl
+ target/debug/uniffi-bindgen-go 3rd-party/uniffi-rs/examples/callbacks/src/callbacks.udl --out-dir /Users/rosssavage/Source/Examples/uniffi-bindgen-go/binding_tests/generated --config=uniffi-test-fixtures.toml
+ bindings 3rd-party/uniffi-rs/examples/custom-types/src/custom-types.udl
+ target/debug/uniffi-bindgen-go 3rd-party/uniffi-rs/examples/custom-types/src/custom-types.udl --out-dir /Users/rosssavage/Source/Examples/uniffi-bindgen-go/binding_tests/generated --config=uniffi-test-fixtures.toml
+ bindings 3rd-party/uniffi-rs/examples/geometry/src/geometry.udl
+ target/debug/uniffi-bindgen-go 3rd-party/uniffi-rs/examples/geometry/src/geometry.udl --out-dir /Users/rosssavage/Source/Examples/uniffi-bindgen-go/binding_tests/generated --config=uniffi-test-fixtures.toml
+ bindings 3rd-party/uniffi-rs/examples/rondpoint/src/rondpoint.udl
+ target/debug/uniffi-bindgen-go 3rd-party/uniffi-rs/examples/rondpoint/src/rondpoint.udl --out-dir /Users/rosssavage/Source/Examples/uniffi-bindgen-go/binding_tests/generated --config=uniffi-test-fixtures.toml
+ bindings 3rd-party/uniffi-rs/examples/sprites/src/sprites.udl
+ target/debug/uniffi-bindgen-go 3rd-party/uniffi-rs/examples/sprites/src/sprites.udl --out-dir /Users/rosssavage/Source/Examples/uniffi-bindgen-go/binding_tests/generated --config=uniffi-test-fixtures.toml
+ bindings 3rd-party/uniffi-rs/examples/todolist/src/todolist.udl
+ target/debug/uniffi-bindgen-go 3rd-party/uniffi-rs/examples/todolist/src/todolist.udl --out-dir /Users/rosssavage/Source/Examples/uniffi-bindgen-go/binding_tests/generated --config=uniffi-test-fixtures.toml
+ bindings 3rd-party/uniffi-rs/fixtures/callbacks/src/callbacks.udl
+ target/debug/uniffi-bindgen-go 3rd-party/uniffi-rs/fixtures/callbacks/src/callbacks.udl --out-dir /Users/rosssavage/Source/Examples/uniffi-bindgen-go/binding_tests/generated --config=uniffi-test-fixtures.toml
+ bindings 3rd-party/uniffi-rs/fixtures/coverall/src/coverall.udl
+ target/debug/uniffi-bindgen-go 3rd-party/uniffi-rs/fixtures/coverall/src/coverall.udl --out-dir /Users/rosssavage/Source/Examples/uniffi-bindgen-go/binding_tests/generated --config=uniffi-test-fixtures.toml
+ bindings 3rd-party/uniffi-rs/fixtures/uniffi-fixture-time/src/chronological.udl
+ target/debug/uniffi-bindgen-go 3rd-party/uniffi-rs/fixtures/uniffi-fixture-time/src/chronological.udl --out-dir /Users/rosssavage/Source/Examples/uniffi-bindgen-go/binding_tests/generated --config=uniffi-test-fixtures.toml
+ bindings fixtures/destroy/src/destroy.udl
+ target/debug/uniffi-bindgen-go fixtures/destroy/src/destroy.udl --out-dir /Users/rosssavage/Source/Examples/uniffi-bindgen-go/binding_tests/generated --config=uniffi-test-fixtures.toml
+ bindings fixtures/errors/src/errors.udl
+ target/debug/uniffi-bindgen-go fixtures/errors/src/errors.udl --out-dir /Users/rosssavage/Source/Examples/uniffi-bindgen-go/binding_tests/generated --config=uniffi-test-fixtures.toml
+ bindings fixtures/objects/src/objects.udl
+ target/debug/uniffi-bindgen-go fixtures/objects/src/objects.udl --out-dir /Users/rosssavage/Source/Examples/uniffi-bindgen-go/binding_tests/generated --config=uniffi-test-fixtures.toml
+ pushd /Users/rosssavage/Source/Examples/uniffi-bindgen-go/binding_tests/generated/..
~/Source/Examples/uniffi-bindgen-go/binding_tests ~/Source/Examples/uniffi-bindgen-go
+ LD_LIBRARY_PATH=:/Users/rosssavage/Source/Examples/uniffi-bindgen-go/target/debug
+ CGO_LDFLAGS='-luniffi_fixtures -L/Users/rosssavage/Source/Examples/uniffi-bindgen-go/target/debug -lm -ldl'
+ CGO_ENABLED=1
+ go test -v
# github.com/NordSecurity/uniffi-bindgen-go/binding_tests/generated/uniffi/callbacks
generated/uniffi/callbacks/callbacks.go:506:14: cannot use FfiConverterTypeCallAnswererINSTANCE.lower(answerer) (value of type _Ctype_ulong) as type _Ctype_ulonglong in variable declaration
# github.com/NordSecurity/uniffi-bindgen-go/binding_tests/generated/uniffi/fixture_callbacks
generated/uniffi/fixture_callbacks/fixture_callbacks.go:648:14: cannot use FfiConverterTypeForeignGettersINSTANCE.lower(callback) (value of type _Ctype_ulong) as type _Ctype_ulonglong in variable declaration
generated/uniffi/fixture_callbacks/fixture_callbacks.go:664:14: cannot use FfiConverterTypeForeignGettersINSTANCE.lower(callback) (value of type _Ctype_ulong) as type _Ctype_ulonglong in variable declaration
generated/uniffi/fixture_callbacks/fixture_callbacks.go:680:14: cannot use FfiConverterTypeForeignGettersINSTANCE.lower(callback) (value of type _Ctype_ulong) as type _Ctype_ulonglong in variable declaration
generated/uniffi/fixture_callbacks/fixture_callbacks.go:696:14: cannot use FfiConverterTypeForeignGettersINSTANCE.lower(callback) (value of type _Ctype_ulong) as type _Ctype_ulonglong in variable declaration
generated/uniffi/fixture_callbacks/fixture_callbacks.go:774:55: cannot use FfiConverterTypeStoredForeignStringifierINSTANCE.lower(callback) (value of type _Ctype_ulong) as type _Ctype_ulonglong in variable declaration
FAIL    github.com/NordSecurity/uniffi-bindgen-go/binding_tests [build failed]
Savolro commented 1 year ago

I made the fix here https://github.com/NordSecurity/uniffi-bindgen-go/pull/5. Issue was caused due to different sizes of ulong on Linux and darwin. This is why it worked on docker as it simulates Linux. Soon we will merge it and make a new release. If you are willing to try it natively:

git checkout darwin-callback-fix
./build.sh
./test_bindings.sh

We'll merge the PR soon and make a new release

dangeross commented 1 year ago

Works 👍