Skip to content

Improve test output and code sharing#3389

Merged
sumneko merged 2 commits intoLuaLS:masterfrom
tommaisey:improve-test-output
Mar 26, 2026
Merged

Improve test output and code sharing#3389
sumneko merged 2 commits intoLuaLS:masterfrom
tommaisey:improve-test-output

Conversation

@tommaisey
Copy link
Copy Markdown
Contributor

While working on a feature I noticed that test output could be more helpful. It now prints the expected and actual results for a failed test.

I also deduplicated some code that was copied across several tests, and made some uses of global TEST variables into locals.

Example output:

test/crossfile/hover.lua:32: 
=================
test failed. got:
=================
```lua
function f(x: number)
```
=================
expected:
=================
```lua
function f(x: number)
```

---

```lua
function f(x: number, y: number)
```
=================

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the testing framework by centralizing comparison logic and improving error reporting for failed assertions. It also cleans up test code by removing redundant comparison functions and localizing test helper functions, leading to more maintainable and informative tests.

Highlights

  • Improved Test Output: Test failures now provide more helpful information by printing both the expected and actual results, making it easier to diagnose issues.
  • Centralized Test Comparison Logic: A new compare module was introduced to centralize the eq (equality) function and EXISTS constant, removing duplicated logic across various test files.
  • Code Deduplication and Refactoring: Duplicated eq functions were removed from multiple test files, and several global TEST functions were converted to local functions, improving code organization and reducing global scope pollution.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@tommaisey tommaisey force-pushed the improve-test-output branch from cf0c662 to e24a746 Compare March 25, 2026 13:15
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors test utility functions by extracting a common compare module. This module provides a deep equality comparison function (compare.eq) and an EXISTS constant. Multiple test files (test/code_action/init.lua, test/completion/init.lua, test/crossfile/completion.lua, test/crossfile/hover.lua, test/crossfile/infer.lua, test/crossfile/references.lua) are updated to import and use this new compare module, removing their duplicate local implementations of eq and EXISTS. A minor improvement opportunity was identified in test/compare.lua regarding a misleading error message in the eq function.

test/compare.lua Outdated
end
for k in pairs(b) do
if not mark[k] then
return false, string.format(".%s: missing key in result", k)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The error message here seems a bit misleading. This loop checks for keys present in the result (b) but not in the expected (a). Therefore, it's an "unexpected" key, not a "missing" one. I suggest changing the message to reflect that.

                return false, string.format(".%s: unexpected key in result", k)

@sumneko sumneko merged commit 9d320a5 into LuaLS:master Mar 26, 2026
10 checks passed
@sumneko
Copy link
Copy Markdown
Collaborator

sumneko commented Mar 26, 2026

Thank you!

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.

2 participants