Skip to content

Commit

Permalink
Merge pull request #20 from vim-denops/v2-pre
Browse files Browse the repository at this point in the history
Support Denops v7 and publish package on JSR
  • Loading branch information
lambdalisue committed May 12, 2024
2 parents 4aa43df + 62224e5 commit 9385b45
Show file tree
Hide file tree
Showing 17 changed files with 99 additions and 91 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/jsr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: jsr

env:
DENO_VERSION: 1.x

on:
push:
tags:
- "v*"

permissions:
contents: read
id-token: write

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}
- name: Publish
run: |
deno run -A jsr:@david/[email protected]
17 changes: 14 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ jobs:
- macos-latest
- ubuntu-latest
deno_version:
- "1.38.x"
- "1.43.x"
- "1.x"
host_version:
- vim: "v9.0.2189"
nvim: "v0.9.4"
- vim: "v9.1.0399"
nvim: "v0.9.5"

runs-on: ${{ matrix.runner }}

Expand Down Expand Up @@ -113,3 +113,14 @@ jobs:
os: ${{ runner.os }}
files: ./coverage.lcov
token: ${{ secrets.CODECOV_TOKEN }}

jsr-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: "1.x"
- name: Publish (dry-run)
run: |
deno publish --dry-run
2 changes: 1 addition & 1 deletion .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
- name: Update dependencies and commit changes
run: deno task -q upgrade:commit --summary ../title.txt --report ../body.md
run: deno task -q update:commit --summary ../title.txt --report ../body.md
- name: Check result
id: result
uses: andstor/file-existence-action@v2
Expand Down
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# 📝 denops_test

[![JSR](https://jsr.io/badges/@denops/test)](https://jsr.io/@denops/test)
[![Test](https://github.com/vim-denops/deno-denops-test/actions/workflows/test.yml/badge.svg)](https://github.com/vim-denops/deno-denops-test/actions/workflows/test.yml)
[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/deno.land/x/denops_test/mod.ts)
[![deno land](http://img.shields.io/badge/available%20on-deno.land/x/denops__test-lightgrey.svg?logo=deno)](https://deno.land/x/denops_test)
[![codecov](https://codecov.io/github/vim-denops/deno-denops-test/branch/main/graph/badge.svg?token=X9O5XB4O1S)](https://codecov.io/github/vim-denops/deno-denops-test)

A [Deno] module designed for testing [denops.vim]. This module is intended to be
Expand Down Expand Up @@ -31,12 +30,8 @@ If you want to test denops plugins with a real Vim and/or Neovim process, use
the `test` function to define a test case, as shown below:

```typescript
import {
assert,
assertEquals,
assertFalse,
} from "https://deno.land/[email protected]/assert/mod.ts";
import { test } from "https://deno.land/x/denops_test@$MODULE_VERSION/mod.ts";
import { assert, assertEquals, assertFalse } from "jsr:@std/assert";
import { test } from "jsr:@denops/test";

test("vim", "Start Vim to test denops features", async (denops) => {
assertFalse(await denops.call("has", "nvim"));
Expand Down Expand Up @@ -72,8 +67,8 @@ the `DenopsStub` class to create a stub instance of the `Denops` interface, as
shown below:

```typescript
import { assertEquals } from "https://deno.land/[email protected]/assert/mod.ts";
import { DenopsStub } from "https://deno.land/x/denops_test@$MODULE_VERSION/mod.ts";
import { assertEquals } from "jsr:@std/assert";
import { DenopsStub } from "jsr:@denops/test";

Deno.test("denops.call", async () => {
const denops = new DenopsStub({
Expand Down Expand Up @@ -158,6 +153,10 @@ jobs:
run: deno test -A
```

## For developers

This library may be called from denops itself so import map is not available.

## License

The code follows the MIT license, as stated in [LICENSE](./LICENSE).
Expand Down
2 changes: 1 addition & 1 deletion conf.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolve } from "https://deno.land/std@0.210.0/path/mod.ts";
import { resolve } from "jsr:@std/path@0.225.0/resolve";

let conf: Config | undefined;

Expand Down
14 changes: 11 additions & 3 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
{
"name": "@denops/test",
"version": "0.0.0",
"exports": {
".": "./mod.ts",
"./stub": "./stub.ts",
"./tester": "./tester.ts",
"./with": "./with.ts"
},
"tasks": {
"check": "deno check **/*.ts",
"test": "deno test -A --doc --parallel --shuffle",
"test:coverage": "deno task test --coverage=.coverage",
"coverage": "deno coverage .coverage",
"upgrade": "deno run -q -A https://deno.land/x/[email protected]/cli.ts ./**/*.ts",
"upgrade:commit": "deno task -q upgrade --commit --prefix :package: --pre-commit=fmt"
"update": "deno run --allow-env --allow-read --allow-write=. --allow-run=git,deno --allow-net=jsr.io,registry.npmjs.org jsr:@molt/cli ./*.ts",
"update:commit": "deno task -q update --commit --pre-commit=fmt,lint"
},
"imports": {
"https://deno.land/x/denops_test@$MODULE_VERSION/": "./"
"jsr:@denops/test": "./mod.ts"
}
}
9 changes: 2 additions & 7 deletions denops.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import type {
Context,
Denops,
Dispatcher,
Meta,
} from "https://deno.land/x/[email protected]/mod.ts";
import { Client } from "https://deno.land/x/[email protected]/mod.ts";
import type { Context, Denops, Dispatcher, Meta } from "jsr:@denops/[email protected]";
import type { Client } from "jsr:@lambdalisue/[email protected]";

export class DenopsImpl implements Denops {
readonly name: string;
Expand Down
4 changes: 2 additions & 2 deletions error.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { is } from "https://deno.land/x/unknownutil@v3.11.0/mod.ts";
import { is } from "jsr:@core/unknownutil@3.18.0";
import {
fromErrorObject,
isErrorObject,
toErrorObject,
tryOr,
} from "https://deno.land/x/errorutil@v0.1.1/mod.ts";
} from "jsr:@lambdalisue/errorutil@1.0.0";

export function errorSerializer(err: unknown): unknown {
if (err instanceof Error) {
Expand Down
8 changes: 4 additions & 4 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
* assert,
* assertEquals,
* assertFalse,
* } from "https://deno.land/[email protected]/assert/mod.ts";
* import { test } from "https://deno.land/x/denops_test@$MODULE_VERSION/mod.ts";
* } from "jsr:@std/assert";
* import { test } from "jsr:@denops/test";
*
* test(
* "vim",
Expand Down Expand Up @@ -68,8 +68,8 @@
* shown below:
*
* ```typescript
* import { assertEquals } from "https://deno.land/[email protected]/assert/mod.ts";
* import { DenopsStub } from "https://deno.land/x/denops_test@$MODULE_VERSION/mod.ts";
* import { assertEquals } from "jsr:@std/assert";
* import { DenopsStub } from "jsr:@denops/test";
*
* Deno.test("denops.call", async () => {
* const denops = new DenopsStub({
Expand Down
13 changes: 3 additions & 10 deletions plugin.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import type { Denops } from "https://deno.land/x/[email protected]/mod.ts";
import {
assert,
ensure,
is,
} from "https://deno.land/x/[email protected]/mod.ts";
import {
Client,
Session,
} from "https://deno.land/x/[email protected]/mod.ts";
import type { Denops } from "jsr:@denops/[email protected]";
import { assert, ensure, is } from "jsr:@core/[email protected]";
import { Client, Session } from "jsr:@lambdalisue/[email protected]";
import { errorDeserializer, errorSerializer } from "./error.ts";

export async function main(denops: Denops): Promise<void> {
Expand Down
8 changes: 4 additions & 4 deletions runner.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { mergeReadableStreams } from "https://deno.land/std@0.210.0/streams/merge_readable_streams.ts";
import { is } from "https://deno.land/x/unknownutil@v3.11.0/mod.ts";
import { unreachable } from "https://deno.land/x/errorutil@v0.1.1/mod.ts";
import { Config, getConfig } from "./conf.ts";
import { mergeReadableStreams } from "jsr:@std/streams@0.224.0/merge-readable-streams";
import { is } from "jsr:@core/unknownutil@3.18.0";
import { unreachable } from "jsr:@lambdalisue/errorutil@1.0.0";
import { type Config, getConfig } from "./conf.ts";

/**
* Represents the mode in which the runner operates.
Expand Down
7 changes: 1 addition & 6 deletions stub.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
Context,
Denops,
Dispatcher,
Meta,
} from "https://deno.land/x/[email protected]/mod.ts";
import type { Context, Denops, Dispatcher, Meta } from "jsr:@denops/[email protected]";

/**
* Represents a stubber object for `Denops`.
Expand Down
9 changes: 3 additions & 6 deletions stub_test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import {
assertSpyCall,
spy,
} from "https://deno.land/[email protected]/testing/mock.ts";
import { assertEquals } from "https://deno.land/[email protected]/assert/mod.ts";
import { Denops } from "https://deno.land/x/[email protected]/mod.ts";
import { assertSpyCall, spy } from "jsr:@std/[email protected]/mock";
import { assertEquals } from "jsr:@std/[email protected]";
import type { Denops } from "jsr:@denops/[email protected]";
import { DenopsStub } from "./stub.ts";

Deno.test("`DenopsStub`", async (t) => {
Expand Down
12 changes: 6 additions & 6 deletions tester.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { sample } from "https://deno.land/std@0.210.0/collections/sample.ts";
import type { Denops } from "https://deno.land/x/denops_core@v6.0.2/mod.ts";
import { sample } from "jsr:@std/collections@0.224.1/sample";
import type { Denops } from "jsr:@denops/core@6.0.6";
import type { RunMode } from "./runner.ts";
import { withDenops } from "./with.ts";

Expand Down Expand Up @@ -45,8 +45,8 @@ export interface TestDefinition extends Omit<Deno.TestDefinition, "fn"> {
* tests by passing a `denops` instance to the registered test function.
*
* ```ts
* import { assert, assertFalse } from "https://deno.land/[email protected]/assert/mod.ts";
* import { test } from "https://deno.land/x/denops_test@$MODULE_VERSION/mod.ts";
* import { assert, assertFalse } from "jsr:@std/assert";
* import { test } from "jsr:@denops/test";
*
* test("vim", "Test with Vim", async (denops) => {
* assertFalse(await denops.call("has", "nvim"));
Expand Down Expand Up @@ -74,8 +74,8 @@ export function test(
* tests by passing a `denops` instance to the registered test function.
*
* ```ts
* import { assert, assertFalse } from "https://deno.land/[email protected]/assert/mod.ts";
* import { test } from "https://deno.land/x/denops_test@$MODULE_VERSION/mod.ts";
* import { assert, assertFalse } from "jsr:@std/assert";
* import { test } from "jsr:@denops/test";
*
* test({
* mode: "nvim",
Expand Down
6 changes: 1 addition & 5 deletions tester_test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
assert,
assertEquals,
assertFalse,
} from "https://deno.land/[email protected]/assert/mod.ts";
import { assert, assertEquals, assertFalse } from "jsr:@std/[email protected]";
import { test } from "./tester.ts";

test({
Expand Down
20 changes: 7 additions & 13 deletions with.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import { deadline } from "https://deno.land/[email protected]/async/mod.ts";
import { assert, is } from "https://deno.land/x/[email protected]/mod.ts";
import {
Client,
Session,
} from "https://deno.land/x/[email protected]/mod.ts";
import type {
Denops,
Meta,
} from "https://deno.land/x/[email protected]/mod.ts";
import { deadline } from "jsr:@std/[email protected]/deadline";
import { assert, is } from "jsr:@core/[email protected]";
import { Client, Session } from "jsr:@lambdalisue/[email protected]";
import type { Denops, Meta } from "jsr:@denops/[email protected]";
import { getConfig } from "./conf.ts";
import { run, RunMode } from "./runner.ts";
import { run, type RunMode } from "./runner.ts";
import { DenopsImpl } from "./denops.ts";
import { errorDeserializer, errorSerializer } from "./error.ts";

Expand Down Expand Up @@ -46,8 +40,8 @@ export interface WithDenopsOptions {
* internally spawns a Vim/Neovim sub-process, which performs the tests.
*
* ```ts
* import { assert, assertFalse } from "https://deno.land/[email protected]/assert/mod.ts";
* import { withDenops } from "https://deno.land/x/denops_test@$MODULE_VERSION/mod.ts";
* import { assert, assertFalse } from "jsr:@std/assert";
* import { withDenops } from "jsr:@denops/test";
*
* Deno.test("Test Denops (Vim)", async () => {
* await withDenops("vim", async (denops) => {
Expand Down
13 changes: 3 additions & 10 deletions with_test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import {
assert,
assertFalse,
assertRejects,
} from "https://deno.land/[email protected]/assert/mod.ts";
import {
assertSpyCalls,
spy,
} from "https://deno.land/[email protected]/testing/mock.ts";
import type { Denops } from "https://deno.land/x/[email protected]/mod.ts";
import { assert, assertFalse, assertRejects } from "jsr:@std/[email protected]";
import { assertSpyCalls, spy } from "jsr:@std/[email protected]/mock";
import type { Denops } from "jsr:@denops/[email protected]";
import { withDenops } from "./with.ts";

Deno.test("test(mode:vim) start vim to test denops features", async () => {
Expand Down

0 comments on commit 9385b45

Please sign in to comment.