{"id":13726522,"url":"https://github.com/yusuf8ahmed/Wasmite","last_synced_at":"2025-05-07T21:33:01.990Z","repository":{"id":65420089,"uuid":"314324111","full_name":"yusuf8ahmed/Wasmite","owner":"yusuf8ahmed","description":"Now WebAssembly has proper testing, unit-testing and debugging 🤗","archived":false,"fork":false,"pushed_at":"2021-02-24T19:27:50.000Z","size":76,"stargazers_count":22,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-13T03:21:11.295Z","etag":null,"topics":["debug","debugger","debugging-tool","debugging-tools","test","test-automation","test-framework","testing","testing-framework","testing-tools","unit-testing","unittest","unittesting","wasm","wasm-bytecode","wasmer","webassemby"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yusuf8ahmed.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-19T17:39:24.000Z","updated_at":"2023-10-04T17:11:03.000Z","dependencies_parsed_at":"2023-01-22T18:45:13.877Z","dependency_job_id":null,"html_url":"https://github.com/yusuf8ahmed/Wasmite","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusuf8ahmed%2FWasmite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusuf8ahmed%2FWasmite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusuf8ahmed%2FWasmite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusuf8ahmed%2FWasmite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yusuf8ahmed","download_url":"https://codeload.github.com/yusuf8ahmed/Wasmite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224654306,"owners_count":17347721,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["debug","debugger","debugging-tool","debugging-tools","test","test-automation","test-framework","testing","testing-framework","testing-tools","unit-testing","unittest","unittesting","wasm","wasm-bytecode","wasmer","webassemby"],"created_at":"2024-08-03T01:03:10.330Z","updated_at":"2024-11-14T16:34:02.578Z","avatar_url":"https://github.com/yusuf8ahmed.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/logo.svg\"/\u003e\n\u003c/p\u003e \n\n### What is the Wasmite project\nSince WebAssembly is the future of the web. I decide to create Wasmite, a python package for unit-testing your wasm or wat code. Wasmite is based on **[wasmer](https://wasmerio.github.io/wasmer-python/api/wasmer/)** and the python standard library package **[unittest](https://docs.python.org/3/library/unittest.html)**. Documentation for can be found here: [documentation for unittest](https://docs.python.org/3/library/unittest.html) and [documentation for wasmer](https://wasmerio.github.io/wasmer-python/api/wasmer/)\n\n**This project was formerly an extension of my Rust/Python Web framework Wasp, so some section of the code may refer to it's earlier name (Native)** \n\nWasmite looks for tests in python files whose names start with test_\\*.py and runs every test_\\* function it discovers. The testing folder has more examples.\n\n**Having any problems or questions create a [issue](https://github.com/yusuf8ahmed/Wasmite/issues/new), i will be happy to help :)**\n\n### Installation\n\nThis project requires python 3 and doesn't support 3.9\n```bash\npip install wasmite\n```\n\n### Project Goals:\n\n- [x] Import wasm or wat module successfully\n- [x] Access functions within module \n- [x] Type checking of parameters and the result of functions\n- [x] Release to **PyPi** for public to use\n- [x] Allow Wasmite ... \n    - [x] Export Python functions\n    - [x] Export Global Instances\n    - [x] Export Memory Instances\n- [x] More complex examples in testing folder\n- [ ] Receive community on how to improve\n\nExamples:\n\n* [c++](https://github.com/yusuf8ahmed/Wasmite/tree/master/examples/c%2B%2B)\n* [c](https://github.com/yusuf8ahmed/Wasmite/tree/master/examples/c)\n* [wasm](https://github.com/yusuf8ahmed/Wasmite/tree/examples/testing/wasm)\n* [wat](https://github.com/yusuf8ahmed/Wasmite/tree/examples/testing/wat)\n\n\n```python\nfrom wasmite import WasmiteCase, WasmModule\nfrom wasmite import FunctionTypes, Function, Global, Value, main\nfrom wasmite import I32\n\ndef sum(x: int, y: int) -\u003e int:\n    \"\"\" python function to be imported into WASM  \"\"\"\n    return x + y\n\nclass Test(WasmiteCase):\n    # create a variable the hold all the functions from a specific wasm file.\n    module = WasmModule(\"test_wasm.wasm\")\n    # import python function into WASM \n    # type annotations on the function is necessary \n    module.register(\"math\", {\n        \"sum\": Function(module.store, sum),\n        \"seven\": Global(module.store, Value.i32(7), mutable=True)\n    })\n    # start up the module and return the exports (this is mandatory)\n    exports = module.get_exports()\n    \n    def test_add(self):\n        # test add function\n        result = self.exports.add(1,2)\n        self.assertEqual(result, 3) \n        \n    def test_sub(self):\n        # test the sub function\n        result = self.exports.sub(2,2)\n        self.assertEqual(result, 0)\n\n    def test_args_add(self):\n        # check the types for results and parameter of the function \"add\"\n        # param is I32, I32 and result is I32\n        add_function = self.exports.add\n        self.assertTypes(add_function, FunctionTypes([I32, I32], [I32])) # result will fail\n        \n    def test_import_sum(self):\n        # test the imported python function sum.\n        sum_function = self.exports.addsum(5,2)\n        self.assertEqual(sum_function, 7)\n        \n    def test_global_read(self):\n        # test reading value of global\n        read_seven = self.exports.read_global()\n        self.assertEqual(read_seven, 7) \n        \n    def test_global_write(self):\n        # test writing value of global\n        self.exports.write_global(5)\n        read_seven = self.exports.read_global()\n        self.assertEqual(read_seven, 5) \n        \n# Hi don't forget to add me         \nif __name__ == \"__main__\":\n    main()\n``` \n--\u003e\n\nThen you can then run this test like so:\n```bash\n# make sure you are in examples/wasm\n$ python test_wasm.py\n\ntest_add (__main__.Test) ... ok\ntest_args_add (__main__.Test) ... ok\ntest_global_read (__main__.Test) ... ok\ntest_global_write (__main__.Test) ... ok\ntest_import_sum (__main__.Test) ... ok\ntest_sub (__main__.Test) ... ok\n\n----------------------------------------------------------------------\nRan 6 tests in 0.001s\n\nOK\n``` \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyusuf8ahmed%2FWasmite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyusuf8ahmed%2FWasmite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyusuf8ahmed%2FWasmite/lists"}