Skip to content

Support running all tests in WebAssembly#89

Merged
JohanMabille merged 2 commits intomainfrom
wasm-more-tests-2
Feb 6, 2026
Merged

Support running all tests in WebAssembly#89
JohanMabille merged 2 commits intomainfrom
wasm-more-tests-2

Conversation

@ianthomas23
Copy link
Member

This PR supports running all existing tests in WebAssembly. I am keeping the use of an "allow list" of test files to run in conftest_wasm.py so that new test files added are not automatically included as I don't fully trust the work flow yet.

The tests run and pass locally for me (with some flakiness, see later). I have also added a CI run test-wasm which will only run on demand rather than automatically.

One change to existing tests is to change the code to read the contents of a file from the form with open(file) as f to the form pathlib.Path.read_text() as the latter is easier to monkeypatch to run in the browser as it is a single atomic action rather than opening a stream to access file contents. It would be good to adopt this approach for future tests too, when they are added.

There are two classes of problem observed:

  1. Some git2cpp commands on error return the expected error text on stderr but have an exit code of zero, which is incorrect. This must be due to some WebAssembly build problem, and is important to fix soon. These specific checks are currently skipped in the WebAssembly tests.
  2. There is some flakiness with failures reported as "bad packet length". This is an incorrect error description and is pretty much a catch-all for any error trying to contact a remote repo. This I will improve/fix in the work I am doing to better patch the WebAssembly build of libgit2 for remote access.

Example local test run output:

$ make test
================================================================= test session starts =================================================================
platform darwin -- Python 3.14.2, pytest-9.0.2, pluggy-1.6.0 -- /Users/iant/micromamba/envs/git2cpp-wasm/bin/python3.14
cachedir: .pytest_cache
rootdir: /Users/iant/github/git2cpp
configfile: .pytest.ini
plugins: anyio-4.12.1, playwright-0.7.2, base-url-2.1.0
collected 102 items                                                                                                                                   

test_add.py::test_add[chromium-] PASSED                                                                                                         [  0%]
test_add.py::test_add_nogit[chromium] PASSED                                                                                                    [  1%]
test_branch.py::test_branch_list[chromium] PASSED                                                                                               [  2%]

<snip>

test_status.py::test_status_new_file[chromium---long---short] PASSED                                                                            [ 99%]
test_status.py::test_status_add_file[chromium---long---short] PASSED                                                                            [100%]

======================================================================= PASSES ========================================================================
=========================================================== 102 passed in 158.10s (0:02:38) ===========================================================
Built target test

@ianthomas23
Copy link
Member Author

Cannot test the new workflow until this PR is merged to main.

@JohanMabille JohanMabille merged commit e00fe2e into main Feb 6, 2026
1 check passed
@JohanMabille JohanMabille deleted the wasm-more-tests-2 branch February 6, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants