Skip to content

Commit

Permalink
Fix test-suite for new GHCUp release (#672)
Browse files Browse the repository at this point in the history
The test-suite has its fair-share of issues and tests some things it is
not supposed to test. We remove tests that do not test functionality
that comes from vscode-haskell.

Overhaul CI to use only ghcup instead 'haskell/action/setup'
  • Loading branch information
fendor authored Aug 8, 2022
1 parent 39dea44 commit c69df99
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 62 deletions.
13 changes: 6 additions & 7 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
version: 2
updates:

# NOTE: Dependabot official configuration documentation:
# https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates#package-ecosystem

# Maintain dependencies for internal GitHub Actions CI for pull requests
- package-ecosystem: "github-actions"
directory: "/"
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: "weekly"
interval: 'weekly'

- package-ecosystem: "npm"
directory: "/"
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: "weekly"
interval: 'weekly'
10 changes: 6 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ jobs:
run: ghcup upgrade -i -f
shell: bash
# Setup the environment for the tests
- name: Ensure there is a supported ghc versions
uses: haskell/actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
- name: Install stack
run: ghcup install stack recommended
- name: Install cabal
run: ghcup install cabal recommended
- name: Install GHC
run: ghcup install ghc ${{matrix.ghc}}
- name: 'Install `tree` for MacOs'
run: |
brew update
Expand Down
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ As almost all features are provided by the server you might find interesting rea

## Table of Contents

* [Setup](#setup)
* [Features](#features)
* [Requirements](#requirements)
* [Configuration options](#configuration-options)
* [Path to server executable](#path-to-server-executable)
* [Security warning](#security-warning)
* [Set additional environment variables for the server](#set-additional-environment-variables-for-the-server)
* [Downloaded binaries](#downloaded-binaries)
* [Setting a specific toolchain](#setting-a-specific-toolchain)
* [Supported GHC versions](#supported-ghc-versions)
* [Using multi-root workspaces](#using-multi-root-workspaces)
* [Investigating and reporting problems](#investigating-and-reporting-problems)
* [FAQ](#faq)
* [Troubleshooting](#troubleshooting)
* [Check issues and tips in the haskell-language-server project](#check-issues-and-tips-in-the-haskell-language-server-project)
* [Restarting the language server](#restarting-the-language-server)
* [Failed to get project GHC version on darwin M1 with stack](#failed-to-get-project-ghc-version-on-darwin-m1-with-stack)
* [GHC ABIs don't match](#ghc-abis-dont-match)
* [Using an old configuration](#using-an-old-configuration)
* [Stack/Cabal/GHC can not be found](#stackcabalghc-can-not-be-found)
* [Contributing](#contributing)
* [Release Notes](#release-notes)
- [Setup](#setup)
- [Features](#features)
- [Requirements](#requirements)
- [Configuration options](#configuration-options)
- [Path to server executable](#path-to-server-executable)
- [Security warning](#security-warning)
- [Set additional environment variables for the server](#set-additional-environment-variables-for-the-server)
- [Downloaded binaries](#downloaded-binaries)
- [Setting a specific toolchain](#setting-a-specific-toolchain)
- [Supported GHC versions](#supported-ghc-versions)
- [Using multi-root workspaces](#using-multi-root-workspaces)
- [Investigating and reporting problems](#investigating-and-reporting-problems)
- [FAQ](#faq)
- [Troubleshooting](#troubleshooting)
- [Check issues and tips in the haskell-language-server project](#check-issues-and-tips-in-the-haskell-language-server-project)
- [Restarting the language server](#restarting-the-language-server)
- [Failed to get project GHC version on darwin M1 with stack](#failed-to-get-project-ghc-version-on-darwin-m1-with-stack)
- [GHC ABIs don't match](#ghc-abis-dont-match)
- [Using an old configuration](#using-an-old-configuration)
- [Stack/Cabal/GHC can not be found](#stackcabalghc-can-not-be-found)
- [Contributing](#contributing)
- [Release Notes](#release-notes)

## Setup

Expand Down Expand Up @@ -267,7 +267,7 @@ setup-info:
ghc:
linux64-tinfo6:
9.0.2:
url: "https://downloads.haskell.org/ghc/9.0.2/ghc-9.0.2a-x86_64-fedora27-linux.tar.xz"
url: 'https://downloads.haskell.org/ghc/9.0.2/ghc-9.0.2a-x86_64-fedora27-linux.tar.xz'
```
Alternatively let GHCup install the correct bindist and then set `system-ghc: true` in your `stack.yaml`.
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ async function activateServerForFolder(context: ExtensionContext, uri: Uri, fold
} else if (e instanceof NoMatchingHls) {
const link = e.docLink();
logger.error(`${e.message}`);
if (await window.showErrorMessage(e.message, `Open documentation`)) {
if (await window.showErrorMessage(e.message, 'Open documentation')) {
env.openExternal(link);
}
} else if (e instanceof Error) {
Expand Down
7 changes: 2 additions & 5 deletions src/hlsBinaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,7 @@ async function callAsync(

/** Gets serverExecutablePath and fails if it's not set.
*/
async function findServerExecutable(
logger: Logger,
folder?: WorkspaceFolder
): Promise<string> {
async function findServerExecutable(logger: Logger, folder?: WorkspaceFolder): Promise<string> {
let exePath = workspace.getConfiguration('haskell').get('serverExecutablePath') as string;
logger.info(`Trying to find the server executable in: ${exePath}`);
exePath = resolvePathPlaceHolders(exePath, folder);
Expand Down Expand Up @@ -200,7 +197,7 @@ export async function findHaskellLanguageServer(
// first plugin initialization
if (manageHLS !== 'GHCup' && (!context.globalState.get('pluginInitialized') as boolean | null)) {
const promptMessage = `How do you want the extension to manage/discover HLS and the relevant toolchain?
Choose "Automatically" if you're in doubt.
`;

Expand Down
22 changes: 0 additions & 22 deletions test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ suite('Extension Test Suite', () => {
vscode.window.showInformationMessage('Start all tests.');

suiteSetup(async () => {
const tmpdir = path.join(getWorkspaceRoot().uri.fsPath, 'tmp');
await deleteWorkspaceFiles([
joinUri(getWorkspaceRoot().uri, '.vscode'),
joinUri(getWorkspaceRoot().uri, 'bin', process.platform === 'win32' ? 'ghcup' : '.ghcup', 'cache'),
Expand All @@ -137,17 +136,10 @@ suite('Extension Test Suite', () => {
await getHaskellConfig().update('releasesDownloadStoragePath', path.normalize(getWorkspaceFile('bin').fsPath));
await getHaskellConfig().update('serverEnvironment', {
XDG_CACHE_HOME: path.normalize(getWorkspaceFile('cache-test').fsPath),
TMPDIR: tmpdir,
TMP: tmpdir,
});
fs.mkdirSync(tmpdir, { recursive: true });
const contents = new TextEncoder().encode('main = putStrLn "hi vscode tests"');
await vscode.workspace.fs.writeFile(getWorkspaceFile('Main.hs'), contents);

const pred = (uri: vscode.Uri) => !['download', 'gz', 'zip'].includes(path.extname(uri.fsPath));
// Setting up watchers before actual tests start, to ensure we will got the created event
filesCreated.set('wrapper', existsWorkspaceFile(`tmp/ghcup-*/haskell-language-server-wrapper*`, pred));
filesCreated.set('server', existsWorkspaceFile(`tmp/ghcup-*/haskell-language-server-[1-9]*`, pred));
filesCreated.set('log', existsWorkspaceFile('hls.log'));
filesCreated.set('cache', existsWorkspaceFile('cache-test'));
});
Expand All @@ -166,20 +158,6 @@ suite('Extension Test Suite', () => {
assert.ok(await withTimeout(90, filesCreated.get('log')!), 'Extension log not created in 30 seconds');
});

test('HLS executables should be downloaded', async () => {
await vscode.workspace.openTextDocument(getWorkspaceFile('Main.hs'));
console.log('Testing wrapper');
assert.ok(
await withTimeout(90, filesCreated.get('wrapper')!),
'The wrapper executable was not downloaded in 90 seconds'
);
console.log('Testing server');
assert.ok(
await withTimeout(90, filesCreated.get('server')!),
'The server executable was not downloaded in 90 seconds'
);
});

test('Extension log should have server output', async () => {
await vscode.workspace.openTextDocument(getWorkspaceFile('Main.hs'));
await delay(20);
Expand Down

0 comments on commit c69df99

Please sign in to comment.