tests: make first_run.v work with current V and on Windows#291
Open
medvednikov wants to merge 1 commit into
Open
tests: make first_run.v work with current V and on Windows#291medvednikov wants to merge 1 commit into
medvednikov wants to merge 1 commit into
Conversation
- Use x.json2 (import x.json2 as json), so the generic json.decode[T](...) or {}
calls compile with the current V compiler (vlib/json expects json.decode(T, s)).
- Compile gitly with -d sqlite, so the test uses the embedded sqlite backend
instead of the default PostgreSQL one and needs no external database.
- Start/stop gitly via os.new_process instead of a Unix-only './gitly.exe &'
plus 'pkill', so the test works on Windows, macOS and Linux, and reliably
shuts the server down (releasing the sqlite file before it is removed).
- Skip -d use_libbacktrace/-d use_openssl on Windows (libbacktrace is not
available there; the native schannel https backend is used instead).
- Add GITLY_TEST_SKIP_REMOTE_REPO to skip the network/git-heavy tests that
clone a remote GitHub repo, so the pure 'serves the expected HTML' checks
can run as a fast, reliable smoke test (e.g. in vlang/v's Windows CI).
4bcc206 to
8d5b688
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Makes
tests/first_run.vcompile with the current V compiler and run on Windows (in addition to macOS/Linux), so it can be used as an end-to-end "gitly serves the expected HTML" test — including fromvlang/v's Windows CI.Why
The test had bit-rotted and no longer ran:
json.decode[T](body) or { … }form, but importedjson(vlib/json, whose API isjson.decode(T, s)). With current V this fails to compile. Fixed byimport x.json2 as json(the convention already used elsewhere in gitly:github.v,webhook.v).-d sqlite, so gitly used its default PostgreSQL backend and panicked at startup (Connection to a PG database failed). Fixed by compiling with-d sqlite(embedded DB, no external service needed).os.execute('./gitly.exe &')and stopped it withpkill -9— both Unix-only. On Windows the server never backgrounded/stopped, andafter()then failed to delete the still-locked sqlite file. Fixed by usingos.new_processfor a cross-platform start +signal_kill/waitstop (DB/repos are removed only after the process exits).-d use_libbacktrace/-d use_opensslare skipped on Windows (libbacktrace isn't available there; the native schannel https backend is used instead).Reliability knob
GITLY_TEST_SKIP_REMOTE_REPO=1skips the tests that clone a remote GitHub repo (network + outbound git/https heavy — the flakiest part). With it set, only the pure HTML/serving checks run (index, register, user page, login, static CSS, oauth, local repo creation). Default behavior (full test) is unchanged.Testing
Validated locally on macOS with the current
vlang/v:GITLY_TEST_SKIP_REMOTE_REPO=1 v -g run tests/first_run.v→ all tests passed, clean shutdown, no leftover process/port.Paired with a new Windows job in
vlang/vthat runs this (smoke mode) to verify gitly (which serves via veb → fasthttp) works on Windows.