test(lsp): give rename_test enough wall time for the LSP to compile the file - #2158
Merged
Conversation
Peefy
force-pushed
the
fix/lsp-rename-test-wait
branch
3 times, most recently
from
August 30, 2026 06:14
4a4f9ba to
aadf30a
Compare
…1874) `file.read()` is a thin wrapper over `fs::read_to_string` and bails on non-UTF-8 input, so it can't be used for binary assets (images, certificates, archives, etc.). Add a `file.readbase64()` companion that reads the raw bytes and returns them as a base64 string (RFC 4648 §4 standard alphabet, with padding), so KCL code can round-trip any byte sequence losslessly. The function is exposed the same way as the other `file.*` builtins: a `kcl_file_readbase64` C-ABI entry point, a `kcl_file_readbase64` declaration in `kcl.h`, the `kcl_file_readbase64` symbol registered in `addr.rs`, and a typed `readbase64` member in the `file` system package's `register_file_member!` block so the type checker knows about the function. A small grammar test exercises both a binary file and a UTF-8 text file: the binary input proves the function preserves arbitrary bytes, the text input proves it's a strict superset of `read()`. Closes #1874 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Claude Opus 4.6 <noreply@anthropic.com>
When the SDK caller passes only k_code_list (no k_filename_list), KCL used to refuse with "No input KCL files or paths" because every entry needed at least one file path. The Python/Go/Java/etc. SDKs are thin gRPC wrappers, so this surfaced in every binding as an unusable exec_program when the caller only has the source string. Build a virtual __main__ entry whose k_files list is synthesized from the inline code snippets (e.g. <work_dir>/__main__.k, <work_dir>/__main__1.k) so the loader can still associate each snippet with a path. Parse errors now report a synthetic __main__.k path so callers can correlate the diagnostic with the snippet they submitted. Only fail when both k_filename_list and k_code_list are empty, which preserves the original "No input KCL files or paths" error. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Claude Opus 4.6 <noreply@anthropic.com>
…pe_mapping
Add a doc-test to get_schema_type_mapping that exercises the
schema [foo: str]: Foo form (named key + non-any-other index
signature) using the k_code_list-only path opened up by the
preceding lib#217 commit. The test asserts:
* properties and required are empty for an index-only schema
(regression for the "bar" leak reported in lib#187),
* index_signature.key_name is "foo",
* index_signature.key.type is "str",
* index_signature.val.schema_name is "Foo",
* index_signature.any_other is false.
The KCL-core conversion (`kcl_schema_ty_to_pb_ty` in ty.rs) already
populates `index_signature` from `SchemaType.index_signature`, but the
public API did not have a regression test pinning this behaviour for
the named-key form (the existing get_schema_ty/bbb fixture only
exercises the `[...str]: int` any-other form).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Claude Opus 4.6 <noreply@anthropic.com>
…he file The rename_test exercised a real race: after `DidOpen` the LSP server kicks off the parse/typecheck of the file in the background, and the test only slept 100 ms before sending `textDocument/rename`. On any slower CI runner (Windows, macos-15-intel) the database hadn't reached `DBState::Ready` yet, so the request hit `handle_rename`, fell into `try_get_db`, and the path either wasn't in the VFS or the analysis db was still `Compiling`. The handler returned `Ok(None)`, the test assertion failed with `left: Null` and the suite went red. Bumping the wait to 1 s matches what the only other LSP test with a real cold-start (the kpm download case) already uses (`wait_async!(2000)`). Verified locally: rename_test now passes deterministically; pkg_mod_test is an unrelated, pre-existing failure caused by a kcl.mod path typo in test_data, not something this test exercises. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Claude Opus 4.6 <noreply@anthropic.com>
Peefy
force-pushed
the
fix/lsp-rename-test-wait
branch
from
August 30, 2026 06:40
aadf30a to
0d36184
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.
Problem
tests::rename_testincrates/tools/src/LSP/src/tests.rsis flaky on slower CI runners (Windows, macos-15-intel, often Linux AMD64). The test sleeps 100 ms afterDidOpenand then sendstextDocument/rename, but the LSP server runs the parse/typecheck asynchronously. On a slow box the analysis db is stillDBState::Compilingwhen the request arrives,handle_renamefalls throughtry_get_dband the handler returnsOk(None). The assertion fails withleft: Null.Fix
Bump the post-
DidOpenwait to 1 s, matching the only other LSP test with a real cold-start (the kpm download case useswait_async!(2000)).Test plan
cargo test -p kcl-language-server --lib tests::rename_test→ passes locally.cargo test -p kcl-language-server --lib→ all other tests pass.tests::pkg_mod_testis a separate, pre-existing failure caused by akcl.modpath typo in test_data (unrelated to this change); tracked separately.🤖 Generated with Claude Code