Skip to content
This repository has been archived by the owner on Jul 26, 2024. It is now read-only.

Commit

Permalink
New Version
Browse files Browse the repository at this point in the history
- Retry dune commands every 2.5s if another process holds the dune directory lock.
- Change the name of the test profile to 'Run Alcotest tests'.
- Set the tests state to 'run' before processing the tests.
- Add documentation of 'Run Profiles'.
- Add GitHub test action.
- Add GitHub Issue Template.
- Add jsdoc plugin for Eslint.
- Fix various jsdoc errors.
- Use function `workspaceLabel` to set the workspace node label and id.
  • Loading branch information
Release-Candidate committed Mar 6, 2023
1 parent 7f36d89 commit d2b3ed6
Show file tree
Hide file tree
Showing 17 changed files with 288 additions and 51 deletions.
13 changes: 10 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,25 @@
"plugins": [
"@typescript-eslint",
"mocha",
"chai-friendly"
"chai-friendly",
"jsdoc"
],
"extends": [
"eslint:recommended",
"plugin:mocha/recommended",
"plugin:chai-friendly/recommended"
"plugin:chai-friendly/recommended",
"plugin:jsdoc/recommended-error"
],
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"rules": {
"jsdoc/require-param-type": "off",
"jsdoc/require-returns-type": "off",
"jsdoc/newline-after-description": "off",
"jsdoc/require-param": "off",
"jsdoc/check-param-names": ["error", {"checkDestructured": false}],
"accessor-pairs": "error",
"array-bracket-newline": "off",
"array-bracket-spacing": [
Expand Down Expand Up @@ -205,7 +212,7 @@
"no-trailing-spaces": "error",
"no-undef-init": "error",
"no-undef": "off",
"no-undefined": "warn",
"no-undefined": "off",
"no-underscore-dangle": "error",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": "error",
Expand Down
40 changes: 40 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Logs**
If applicable, add logs of the extension (Output of `Alcotest Tests`), the Extension Host (Ouput of `Extension Host`) and Window (Output of `Window`).

**Example OCaml project**
If possible, add a link to an OCaml project to reproduce the problem with.

**Environment (please complete the following information):**

- Version of the extension:
- Version of VS Code:
- OS: [e.g.Linux]

**Additional context**
Add any other context about the problem here.
40 changes: 40 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# SPDX-License-Identifier: MIT
# Copyright (C) 2023 Roland Csaszar
#
# Project: vscode-ocaml-alcotest-test-adapter
# File: test.yml
# Date: 06.Mar.2023
#
# ==============================================================================


name: Test

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
tests:
strategy:
matrix:
os: [ubuntu-latest]
node-version: [16.x, 18.x]

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

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Run Tests
run: |
yarn --ignore-engines install --dev
xvfb-run -a yarn --ignore-engines test
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# OCaml Alcotest Test Explorer for Visual Studio Code Changelog

## Version 0.3.0 (2023-03-06)

- Retry dune commands every 2.5s if another process holds the dune directory lock.
- Change the name of the test profile to 'Run Alcotest tests'.
- Set the tests state to 'run' before processing the tests.
- Add documentation of 'Run Profiles'.

### Internal Changes

- Add GitHub test action.
- Add GitHub Issue Template.
- Add jsdoc plugin for Eslint.
- Fix various jsdoc errors.
- Use function `workspaceLabel` to set the workspace node label and id.

## Version 0.2.0 (2023-02-27)

- Drop support for VS Code versions < 1.65 (February 2022) because of [Testing refresh action](https://code.visualstudio.com/updates/v1_65#_testing-refresh-action-and-sorttext)
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# OCaml Alcotest Test Explorer for Visual Studio Code

[![Tests](https://github.com/Release-Candidate/vscode-ocaml-alcotest-test-adapter/actions/workflows/test.yml/badge.svg)](https://github.com/Release-Candidate/vscode-ocaml-alcotest-test-adapter/actions/workflows/test.yml)
[![Lint](https://github.com/Release-Candidate/vscode-ocaml-alcotest-test-adapter/actions/workflows/lint.yml/badge.svg)](https://github.com/Release-Candidate/vscode-ocaml-alcotest-test-adapter/actions/workflows/lint.yml)
[![Release](https://github.com/Release-Candidate/vscode-ocaml-alcotest-test-adapter/actions/workflows/release.yml/badge.svg)](https://github.com/Release-Candidate/vscode-ocaml-alcotest-test-adapter/actions/workflows/release.yml)
[![Visual Studio Marketplace Downloads](https://img.shields.io/visual-studio-marketplace/d/Release-Candidate.vscode-ocaml-alcotest-test-adapter)](https://marketplace.visualstudio.com/items?itemName=release-candidate.vscode-ocaml-alcotest-test-adapter)
[![Visual Studio Marketplace Installs](https://img.shields.io/visual-studio-marketplace/i/Release-Candidate.vscode-ocaml-alcotest-test-adapter)](https://marketplace.visualstudio.com/items?itemName=release-candidate.vscode-ocaml-alcotest-test-adapter)
[![Visual Studio Marketplace Version](https://img.shields.io/visual-studio-marketplace/v/Release-Candidate.vscode-ocaml-alcotest-test-adapter)](https://marketplace.visualstudio.com/items?itemName=release-candidate.vscode-ocaml-alcotest-test-adapter)

![Alcotest logo](./images/alcotest-logo_rect.png)
Expand All @@ -22,7 +24,8 @@ This extension lets you run OCaml [Alcotests](https://github.com/mirage/alcotest
- [Q: A test has been added, how can I add that to the Test Explorer?](#q-a-test-has-been-added-how-can-i-add-that-to-the-test-explorer)
- [Q: I am not seeing the full name of my test case, why?](#q-i-am-not-seeing-the-full-name-of-my-test-case-why)
- [Q: Where can I see the output of the test run(s)?](#q-where-can-i-see-the-output-of-the-test-runs)
- [Q: What does the red circle with a point in the middle mean?](#q-what-does-the-red-circle-with-a-point-in-the-middle-mean)
- [Q: How can I change which test extension's tests are run by the `Run Tests` button in the upper right of the Test Explorer?](#q-how-can-i-change-which-test-extensions-tests-are-run-by-the-run-tests-button-in-the-upper-right-of-the-test-explorer)
- [Q: What does the red circle with a dot in the middle mean?](#q-what-does-the-red-circle-with-a-dot-in-the-middle-mean)
- [Q: Where can I see the log of the extension?](#q-where-can-i-see-the-log-of-the-extension)
- [Q: I have two or more test cases with the same name in the same file, why are they all pointing to the first test case in the source file?](#q-i-have-two-or-more-test-cases-with-the-same-name-in-the-same-file-why-are-they-all-pointing-to-the-first-test-case-in-the-source-file)
- [Configuration](#configuration)
Expand Down Expand Up @@ -101,7 +104,13 @@ click on `Go To Test` to the right of a failed test in the test explorer and the
or hover over the [Error Lens](https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens) output in the source file - this preview is too narrow, so the test output is mangled.
![HOver over the Error Lens text](https://raw.githubusercontent.com/Release-Candidate/vscode-ocaml-alcotest-test-adapter/main/images/hover_error_lens.png)

#### Q: What does the red circle with a point in the middle mean?
#### Q: How can I change which test extension's tests are run by the `Run Tests` button in the upper right of the Test Explorer?

![Set default run profiles](https://raw.githubusercontent.com/Release-Candidate/vscode-ocaml-alcotest-test-adapter/main/images/run_profiles.png)

A: Click the down arrow to the right of the `Run Tests` button, there you can set the profiles using `Select Default Profile(s)`.

#### Q: What does the red circle with a dot in the middle mean?

![Compile error](https://raw.githubusercontent.com/Release-Candidate/vscode-ocaml-alcotest-test-adapter/main/images/compile_error.png)
A: That means that dune returned an error (not a failed test). Mostly because of code that does not compile.
Expand Down
Binary file added images/run_profiles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vscode-ocaml-alcotest-test-adapter",
"displayName": "OCaml Alcotest Test Explorer",
"version": "0.2.0",
"version": "0.3.0",
"preview": false,
"publisher": "release-candidate",
"description": "Support for OCaml Alcotest and Alcotest inline PPX tests.",
Expand Down Expand Up @@ -86,6 +86,7 @@
"esbuild": "^0.17.10",
"eslint": "^8.35.0",
"eslint-plugin-chai-friendly": "^0.7.2",
"eslint-plugin-jsdoc": "^40.0.1",
"eslint-plugin-mocha": "^10.1.0",
"glob": "^8.1.0",
"mocha": "^10.2.0",
Expand Down
12 changes: 11 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,23 @@ export const outputChannelName = "Alcotest Tests";
/**
* The label of the `TestRunProfileKind.Run` test profile.
*/
export const runProfileLabel = "Run test";
export const runProfileLabel = "Run Alcotest tests";

/**
* The label of root of the inline test tree in the Test Explorer view.
*/
export const inlineTestsLabel = "Inline Tests (PPX)";

/**
* Return the visible name of the workspace.
* In the format: `Workspace: ID`.
* @param id The id of the workspace.
* @returns The visible name of the workspace.
*/
export function workspaceLabel(id: string) {
return `Workspace: ${id}`;
}

/**
* Glob to search for sources of tests.
*/
Expand Down
3 changes: 1 addition & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import * as vscode from "vscode";
* That is, the registered `Activation Event` has happened. The
* `Activation Events` are configured in `package.json`, in the
* `activationEvents` field.
*
* @param _context The `vscode.ExtensionContext` to use.
* @param context The `vscode.ExtensionContext` to use.
*/
export async function activate(context: vscode.ExtensionContext) {
const outChannel = vscode.window.createOutputChannel(c.outputChannelName);
Expand Down
3 changes: 2 additions & 1 deletion src/extension_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ export function testItemsToWorkspaces(items: readonly vscode.TestItem[]) {

/**
* Return the start and end line and column of the test in a source file.
* @param data The data needed to get the source location.
* @param test The test to process.
* @param testData The additional test data to use.
* @returns A `Location` containing a `Range` of the error or `undefined`.
*/
export async function setSourceLocation(
Expand Down
8 changes: 5 additions & 3 deletions src/list_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export async function addTests(

/**
* Add all tests of a single workspace `root` to the Test Explorer.
* @param root The workspace to add the tests from.
* @param env Everything needed to add these tests.
* @param root The workspace to add the tests from.
* @returns The list of `TestItems` that have been deleted from the Test
* Explorer tree.
*/
Expand All @@ -71,6 +71,8 @@ async function addWorkspaceTests(env: h.Env, root: vscode.WorkspaceFolder) {
/**
* Return the `TestItem` of the current workspace if it does exist or create
* it.
* @returns The `TestItem` of the current workspace if it does exist or create
* it.
*/
function getWorkspaceItem() {
const item = env.controller.items.get(root.name);
Expand All @@ -80,7 +82,7 @@ async function addWorkspaceTests(env: h.Env, root: vscode.WorkspaceFolder) {

return env.controller.createTestItem(
root.name,
`Workspace: ${root.name}`,
c.workspaceLabel(root.name),
root.uri
);
}
Expand Down Expand Up @@ -314,9 +316,9 @@ function deleteNonExistingGroups(

/**
* Removes all deleted tests from the test tree.
* @param env The Extension's environment.
* @param group The test group to check for deleted items.
* @param groupItem The `TestItem` of `group`.
* @param env The Extension's environment.
* @returns The list of `TestItems` that have been deleted from the Test
* Explorer tree.
*/
Expand Down
Loading

0 comments on commit d2b3ed6

Please sign in to comment.