Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ports/go: add more type conversions and tests #407

Merged
merged 1 commit into from
Mar 29, 2023

Conversation

iyear
Copy link
Contributor

@iyear iyear commented Mar 27, 2023

Description

  • Small refactorings.
  • Remove useless buffer of all channels. (consumer always faster than producer)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Documentation update

Checklist:

  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests/screenshots (if any) that prove my fix is effective or that my feature works.
  • I have tested the tests implicated (if any) by my own code and they pass (make test or ctest -VV -R <test-name>).
  • If my change is significant or breaking, I have passed all tests with ./docker-compose.sh test &> output and attached the output.
  • I have tested my code with OPTION_BUILD_SANITIZER or ./docker-compose.sh test-sanitizer &> output and OPTION_TEST_MEMORYCHECK.
  • I have tested my code with OPTION_BUILD_THREAD_SANITIZER or ./docker-compose.sh test-thread-sanitizer &> output.
  • I have tested with Helgrind in case my code works with threading.
  • I have run make clang-format in order to format my code and my code follows the style guidelines.

If you are unclear about any of the above checks, have a look at our documentation here.

@iyear
Copy link
Contributor Author

iyear commented Mar 27, 2023

We need to refine the tests first before we start refactoring.

@iyear iyear closed this Mar 27, 2023
@iyear iyear reopened this Mar 27, 2023
@iyear iyear marked this pull request as draft March 27, 2023 08:58
@viferga
Copy link
Member

viferga commented Mar 27, 2023

I have reverted your last PR changes: 1b8cd13

Do not modify the code if it does not add any value, for example linters etc.. or removing optional types, or just refactoring the ifs into switch, it changes the behavior because it removes the check of the casting if it was ok or not.

You can add more type conversions, but remember, LONG is int64, not 32.

I am also adding tests, for each code you add, please test it. You can add a folder called test with all the scripts for testing if you want, and verify each type you add that works.

@viferga
Copy link
Member

viferga commented Mar 27, 2023

$ ctest -VV -R go_port
UpdateCTestConfiguration  from :/media/sf_koyanisqaatsi/metacall-core/build/DartConfiguration.tcl
Parse Config file:/media/sf_koyanisqaatsi/metacall-core/build/DartConfiguration.tcl
UpdateCTestConfiguration  from :/media/sf_koyanisqaatsi/metacall-core/build/DartConfiguration.tcl
Parse Config file:/media/sf_koyanisqaatsi/metacall-core/build/DartConfiguration.tcl
Test project /media/sf_koyanisqaatsi/metacall-core/build
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 1
    Start 1: go_port

1: Test command: /usr/local/go/bin/go "test"
1: Test timeout computed to be: 1500
1: Information: Set MetaCall log level to Debug
1: Debug: Loader script path: /tmp/go-build2208275168/b001/
1: Debug: Loader __metacall_host__ registered at position (0) in thread #380474
1: Debug: Loader host initialized
1: Debug: Loading plugin: ext_loader
1: Error: DynLink error: /usr/local/lib/libext_loader.so: cannot open shared object file: No such file or directory
1: Error: Failed to load library from plugin descriptor
1: Error: Plugin loader from manager 'loader' failed to load plugin: ext
1: Error: Failed to create loader: ext
1: Error: Tried to load 1 file(s) from non existent loader (ext): plugin_extension
1: Warning: MetaCall Plugin Extension could not be loaded
1: Debug: Loading plugin: node_loader
1: Debug: Loading plugin symbol: dynlink_symbol_node_loader_impl_interface_singleton
1: Debug: Created loader (node) implementation <0x24e6ed0>
1: Debug: Loading buffer from memory (node):
1: module.exports = { benchmark: async x => x }
1: Debug: Loading from memory module.exp...
1: Debug: Loader node registered at position (1) in thread #380474
1: Debug: Loader interface: 0x7f8301536620 - Loader handle: 0x7f82e4164210
1: Debug: Loading plugin: mock_loader
1: Debug: Loading plugin symbol: dynlink_symbol_mock_loader_impl_interface_singleton
1: Debug: Created loader (mock) implementation <0x24e4640>
1: Debug: Loading 1 file(s) (mock) from path(s): test.mock ...
1: Debug: Loading test.mock
1: Debug: Loader mock registered at position (2) in thread #380474
1: Debug: Mock module test.mock loaded from file
1: Debug: Loader interface: 0x7f83018c2140 - Loader handle: 0x25263e0
1: Debug: Loader handle impl: 0x2526440
1: Debug: Mock module 0x25263e0 discovering
1: Debug: Loader (mock) get value: three_str <0x2528368>
1: Debug: Invoking mock function three_str
1: Debug: Type 0x2525ff0, 7
1: Debug: String value: e
1: Debug: Type 0x2525ff0, 7
1: Debug: String value: f
1: Debug: Type 0x2525ff0, 7
1: Debug: String value: g
1: Debug: Calling mock function with arguments (3)
1: Debug: Return type 0x2525ff0, 7
1: Debug: Loading buffer from memory (node):
1: module.exports = { g: () => [0, 1, 2] }
1: Debug: Loading from memory module.exp...
1: Debug: Loader interface: 0x7f8301536620 - Loader handle: 0x7f82e4164410
1: Debug: Loader (node) get value: g <0x7f82e41646f8>
1: Debug: Loading buffer from memory (node):
1: module.exports = { f: async (ms) => await new Promise(resolve => setTimeout(resolve, ms)) }
1: Debug: Loading from memory module.exp...
1: Debug: Loader interface: 0x7f8301536620 - Loader handle: 0x7f82e41651e0
1: Debug: Loader (node) get value: f <0x7f82e4165418>
1: Debug: Await function (f) with args <0x24e6360>
1: Debug: Destroy future value <0x7f82e4164c98>
1: 2023/03/28 02:54:15 from go resolve
1: PASS
1: ok  	github.com/metacall/core/source/ports/go_port/source	0.735s
1/1 Test #1: go_port ..........................   Passed    3.79 sec

The following tests passed:
	go_port

100% tests passed, 0 tests failed out of 1

Label Time Summary:
go_port    =   3.79 sec*proc (1 test)

Total Test time (real) =   4.02 sec

@viferga
Copy link
Member

viferga commented Mar 27, 2023

I am not gonna merge any other commit if you don't do TDD or you don't follow the instructions, neither Gil will merge it. It's just a way to prevent breaking things all the time, the project is big and there's not a lot of QA people for verifying it works properly, so TDD is super important.

@viferga
Copy link
Member

viferga commented Mar 27, 2023

Also this commit for example, the one you have in the draft, it does not add any value, so this kind of commits won't be merged neither, you are free to add new type conversions but do not touch anything else if the refactor is not completely justified.

@iyear iyear changed the title ports/go: refactor ports/go: add more type conversions and tests Mar 28, 2023
@iyear
Copy link
Contributor Author

iyear commented Mar 28, 2023

The new code is pushed, please review.

I see that a1a079f was able to run go_ports tests in CI(I'm not familiar with C toolchain), do I still need to add a new CI test for go_ports?

Test result:

root@70b6b85094d2:~# go test -v
NodeJS Warning: MetaCall could not be preloaded
=== RUN   TestMock
--- PASS: TestMock (0.00s)
=== RUN   TestNodeJSArray
--- PASS: TestNodeJSArray (0.00s)
=== RUN   TestNodeJSAwait
2023/03/28 08:30:27 from go resolve
--- PASS: TestNodeJSAwait (0.30s)
=== RUN   TestValues
--- PASS: TestValues (0.00s)
PASS
ok      github.com/metacall/core/source/ports/go_port/source    0.420s

@viferga
Copy link
Member

viferga commented Mar 28, 2023

@iyear I am working on it, as soon as it is ready I will merge your changes and we will be able to check the result of the test in the CI (at least in linux).

@viferga viferga marked this pull request as ready for review March 29, 2023 22:50
@viferga viferga merged commit 384e31f into metacall:develop Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants