test(lsp): smoke-test everyday code intelligence per language with real servers (#1299)

* test(lsp): smoke-test everyday code intelligence per language with real servers

A new ide-host integration test drives completion, go to definition, Find
Usages, hover, diagnostics with a quick fix, an intention, formatting and
rename on each language's fixtures/ project, through the ops the app's
commands call and the language server the app starts by default:
TypeScript (vtsls), Python (basedpyright + Ruff), Rust (rust-analyzer),
Go (gopls), Java (jdtls) and Kotlin (kotlin-lsp). A failure names the
language and the operation.

The tests are ignored by default; a Language smoke workflow installs pinned
server versions and runs one language per job on changes to crates/,
languages/ and fixtures/. Adds fixtures/java-app (Maven, JDK 21) for Java.

* test(lsp): rename TypeScript from a usage and check Rust errors while typing

Covers the fixes the smoke test turned up: a TypeScript rename started at a
call site in another file renames the declaration (#1301), and rust-analyzer's
own diagnostics and fixes arrive without saving (#1306).
This commit is contained in:
l0ng-ai
2026-11-04 23:35:53 +08:00
committed by GitHub
parent 1789dbb98e
commit 1e4eee27c4
10 changed files with 963 additions and 0 deletions
@@ -0,0 +1,16 @@
package com.example.orders;
public class App {
public static void main(String[] args) {
OrderBook book = new OrderBook();
book.place("alice", "Mechanical keyboard", 1, 8999);
book.place("bob", "Wireless mouse", 2, 2999);
book.place("alice", "USB-C hub", 1, 3999);
int unused = 42; // intentional warning: unused variable
// Set a breakpoint here (QA: debugger) and inspect `book`.
long revenue = book.revenueCents();
System.out.printf("%d orders, revenue %.2f%n", book.size(), revenue / 100.0);
book.largest().ifPresent(o -> System.out.println("Largest: " + o.product()));
}
}
@@ -0,0 +1,14 @@
package com.example.orders;
/** A customer order: a product, how many and the unit price in cents. */
public record Order(String customer, String product, int quantity, long unitPriceCents) {
public Order {
if (quantity <= 0) throw new IllegalArgumentException("quantity must be positive");
}
/** The order's total in cents. */
public long totalCents() {
return unitPriceCents * quantity;
}
}
@@ -0,0 +1,35 @@
package com.example.orders;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
/** Keeps the orders placed so far, in the order they were placed. */
public class OrderBook {
private final List<Order> orders = new ArrayList<>();
/** Places an order and returns it. */
public Order place(String customer, String product, int quantity, long unitPriceCents) {
Order order = new Order(customer, product, quantity, unitPriceCents);
orders.add(order);
return order;
}
public List<Order> byCustomer(String customer) {
return orders.stream().filter(o -> o.customer().equals(customer)).toList();
}
public Optional<Order> largest() {
return orders.stream().max(Comparator.comparingLong(Order::totalCents));
}
// TODO: discounts for repeat customers
public long revenueCents() {
return orders.stream().mapToLong(Order::totalCents).sum();
}
public int size() {
return orders.size();
}
}
@@ -0,0 +1,29 @@
package com.example.orders;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
class OrderBookTest {
@Test
void sumsRevenueOverAllOrders() {
OrderBook book = new OrderBook();
book.place("alice", "Keyboard", 2, 1000);
book.place("bob", "Mouse", 1, 500);
assertEquals(2500, book.revenueCents());
assertEquals(1, book.byCustomer("bob").size());
}
@Test
void rejectsEmptyOrders() {
assertThrows(IllegalArgumentException.class, () -> new Order("alice", "Keyboard", 0, 1000));
}
@Test
@EnabledIfSystemProperty(named = "openidea.fail", matches = "true")
void intentionallyFails() {
assertEquals(1, new OrderBook().size(), "QA: an intentionally failing test");
}
}