Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ on:
jobs:
test:
runs-on: ${{ matrix.os }}
timeout-minutes: 40
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
nvim-versions: ["stable", "nightly"]
Expand Down
1 change: 1 addition & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ globals = {
'vim.bo',
'vim.opt',
'vim.lsp',
'vim.ui',
}
read_globals = {
'vim',
Expand Down
16 changes: 8 additions & 8 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,22 @@ plugin/java.lua # User command registration

```
tests/
├── assets/ # Test fixtures and assets (e.g., HelloWorld.java)
├── constants/ # Test constants (e.g., capabilities.lua)
├── fixtures/ # Test projects (e.g., demo/ - Maven project with JUnit tests)
├── utils/ # Test utilities and config files
│ ├── lsp-utils.lua # LSP test helpers
│ ├── project.lua # Fixture project + wait/assert helpers
│ ├── prepare-config.lua # Lazy.nvim test setup
│ └── test-config.lua # Manual test setup
│ └── test-config.lua # Minimal init for plenary child nvim
└── specs/ # Test specifications
├── lsp_spec.lua # All LSP-related tests
└── pkgm_spec.lua # All pkgm-related tests
└── integration_spec.lua # End-to-end plugin feature tests
```

**Test Guidelines:**
- Group related tests in single spec file (e.g., all pkgm tests in `pkgm_spec.lua`)
- Tests are end-to-end: real Neovim + real JDTLS against fixture Maven project
- Fixture projects are copied to a temp dir at runtime (root markers prefer `.git`, so they must run outside the repo)
- Spec `it` blocks run sequentially and share JDTLS session state; order matters
- Extract reusable logic to `utils/` to keep test steps clean
- Store test data/fixtures in `assets/`
- Store constants (capabilities, expected values) in `constants/`
- Store test projects in `fixtures/`

## Code Patterns

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ TESTS_ROOT=tests
TESTS_DIR?=${TESTS_ROOT}/specs
PREPARE_CONFIG=${TESTS_ROOT}/utils/prepare-config.lua
TEST_CONFIG=${TESTS_ROOT}/utils/test-config.lua
TEST_TIMEOUT?=60000
TEST_TIMEOUT?=600000

.PHONY: test tests lint format all

Expand Down
18 changes: 11 additions & 7 deletions lua/pkgm/downloaders/curl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@ end
---@return string|nil # Error message if failed
function Curl:download()
log.debug('curl downloading:', self.url, 'to', self.dest)
local cmd = string.format(
'curl --retry %d --connect-timeout %d -o %s %s',
self.retry_count,
self.timeout,
vim.fn.shellescape(self.dest),
vim.fn.shellescape(self.url)
)
-- argv list so no shell quoting is involved
local cmd = {
'curl',
'--retry',
tostring(self.retry_count),
'--connect-timeout',
tostring(self.timeout),
'-o',
self.dest,
self.url,
}
log.debug('curl command:', cmd)

local result = vim.fn.system(cmd)
Expand Down
17 changes: 12 additions & 5 deletions lua/pkgm/downloaders/powershell.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,19 @@ function PowerShell:download()
self.dest
)

local cmd = string.format(
-- luacheck: ignore
"%s -NoProfile -NonInteractive -Command \"$ProgressPreference = 'SilentlyContinue'; $ErrorActionPreference = 'Stop'; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; %s\"",
-- pass an argv list so no shell is involved; a single command string
-- breaks when &shell is pwsh (nvim nightly default on Windows)
local cmd = {
pwsh,
pwsh_cmd
)
'-NoProfile',
'-NonInteractive',
'-Command',
string.format(
-- luacheck: ignore
"$ProgressPreference = 'SilentlyContinue'; $ErrorActionPreference = 'Stop'; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; %s",
pwsh_cmd
),
}
log.debug('PowerShell command:', cmd)

local result = vim.fn.system(cmd)
Expand Down
18 changes: 11 additions & 7 deletions lua/pkgm/downloaders/wget.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@ end
---@return string|nil # Error message if failed
function Wget:download()
log.debug('wget downloading:', self.url, 'to', self.dest)
local cmd = string.format(
'wget -t %d -T %d -O %s %s',
self.retry_count,
self.timeout,
vim.fn.shellescape(self.dest),
vim.fn.shellescape(self.url)
)
-- argv list so no shell quoting is involved
local cmd = {
'wget',
'-t',
tostring(self.retry_count),
'-T',
tostring(self.timeout),
'-O',
self.dest,
self.url,
}
log.debug('wget command:', cmd)

local result = vim.fn.system(cmd)
Expand Down
17 changes: 12 additions & 5 deletions lua/pkgm/extractors/powershell.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,19 @@ function PowerShellExtractor:extract()
self.dest
)

local cmd = string.format(
--luacheck: ignore
"%s -NoProfile -NonInteractive -Command \"$ProgressPreference = 'SilentlyContinue'; $ErrorActionPreference = 'Stop'; %s\"",
-- pass an argv list so no shell is involved; a single command string
-- breaks when &shell is pwsh (nvim nightly default on Windows)
local cmd = {
pwsh,
pwsh_cmd
)
'-NoProfile',
'-NonInteractive',
'-Command',
string.format(
-- luacheck: ignore
"$ProgressPreference = 'SilentlyContinue'; $ErrorActionPreference = 'Stop'; %s",
pwsh_cmd
),
}
log.debug('PowerShell command:', cmd)

local result = vim.fn.system(cmd)
Expand Down
33 changes: 15 additions & 18 deletions lua/pkgm/extractors/tar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,24 @@ function Tar:extract()
log.debug('tar extracting:', self.source, 'to', self.dest)
log.debug('Using tar binary:', tar_cmd)

local cmd
local source = self.source
local dest = self.dest

-- argv list so no shell quoting is involved (&shell may be pwsh on
-- Windows nvim nightly)
local cmd = { tar_cmd, '--no-same-owner' }

if system.get_os() == 'win' then
-- Windows: convert backslashes to forward slashes (tar accepts them)
local source = self.source:gsub('\\', '/')
local dest = self.dest:gsub('\\', '/')
cmd = string.format(
'%s --no-same-owner %s -xf "%s" -C "%s"',
tar_cmd,
self:tar_supports_force_local(tar_cmd) and '--force-local' or '',
source,
dest
)
else
-- Unix: use shellescape
cmd = string.format(
'%s --no-same-owner -xf %s -C %s',
tar_cmd,
vim.fn.shellescape(self.source),
vim.fn.shellescape(self.dest)
)
source = source:gsub('\\', '/')
dest = dest:gsub('\\', '/')

if self:tar_supports_force_local(tar_cmd) then
table.insert(cmd, '--force-local')
end
end

vim.list_extend(cmd, { '-xf', source, '-C', dest })
log.debug('tar command:', cmd)

local result = vim.fn.system(cmd)
Expand Down
3 changes: 2 additions & 1 deletion lua/pkgm/extractors/unzip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ end
---@return string|nil # Error message if failed
function Unzip:extract()
log.debug('unzip extracting:', self.source, 'to', self.dest)
local cmd = string.format('unzip -q -o %s -d %s', vim.fn.shellescape(self.source), vim.fn.shellescape(self.dest))
-- argv list so no shell quoting is involved
local cmd = { 'unzip', '-q', '-o', self.source, '-d', self.dest }
log.debug('unzip command:', cmd)

local result = vim.fn.system(cmd)
Expand Down
81 changes: 0 additions & 81 deletions tests/constants/capabilities.lua

This file was deleted.

25 changes: 25 additions & 0 deletions tests/fixtures/demo/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

<properties>
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
11 changes: 11 additions & 0 deletions tests/fixtures/demo/src/main/java/com/example/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.example;

public class Main {
public static void main(String[] args) {
System.out.println(greet());
}

public static String greet() {
return "Hello from nvim-java";
}
}
18 changes: 18 additions & 0 deletions tests/fixtures/demo/src/test/java/com/example/MainTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;

class MainTest {
@Test
void greetReturnsGreeting() {
assertEquals("Hello from nvim-java", Main.greet());
}

@Test
void greetIsNotEmpty() {
assertTrue(Main.greet().length() > 0);
}
}
27 changes: 0 additions & 27 deletions tests/specs/capabilities_spec.lua

This file was deleted.

Loading
Loading