Skip to content

Commit c69df99

Browse files
authored
Fix test-suite for new GHCUp release (#672)
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'
1 parent 39dea44 commit c69df99

File tree

6 files changed

+38
-62
lines changed

6 files changed

+38
-62
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
version: 2
22
updates:
3-
43
# NOTE: Dependabot official configuration documentation:
54
# https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates#package-ecosystem
65

76
# Maintain dependencies for internal GitHub Actions CI for pull requests
8-
- package-ecosystem: "github-actions"
9-
directory: "/"
7+
- package-ecosystem: 'github-actions'
8+
directory: '/'
109
schedule:
11-
interval: "weekly"
10+
interval: 'weekly'
1211

13-
- package-ecosystem: "npm"
14-
directory: "/"
12+
- package-ecosystem: 'npm'
13+
directory: '/'
1514
schedule:
16-
interval: "weekly"
15+
interval: 'weekly'

.github/workflows/test.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ jobs:
2525
run: ghcup upgrade -i -f
2626
shell: bash
2727
# Setup the environment for the tests
28-
- name: Ensure there is a supported ghc versions
29-
uses: haskell/actions/setup@v2
30-
with:
31-
ghc-version: ${{ matrix.ghc }}
28+
- name: Install stack
29+
run: ghcup install stack recommended
30+
- name: Install cabal
31+
run: ghcup install cabal recommended
32+
- name: Install GHC
33+
run: ghcup install ghc ${{matrix.ghc}}
3234
- name: 'Install `tree` for MacOs'
3335
run: |
3436
brew update

README.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,28 @@ As almost all features are provided by the server you might find interesting rea
77

88
## Table of Contents
99

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

3333
## Setup
3434

@@ -267,7 +267,7 @@ setup-info:
267267
ghc:
268268
linux64-tinfo6:
269269
9.0.2:
270-
url: "https://downloads.haskell.org/ghc/9.0.2/ghc-9.0.2a-x86_64-fedora27-linux.tar.xz"
270+
url: 'https://downloads.haskell.org/ghc/9.0.2/ghc-9.0.2a-x86_64-fedora27-linux.tar.xz'
271271
```
272272
273273
Alternatively let GHCup install the correct bindist and then set `system-ghc: true` in your `stack.yaml`.

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ async function activateServerForFolder(context: ExtensionContext, uri: Uri, fold
179179
} else if (e instanceof NoMatchingHls) {
180180
const link = e.docLink();
181181
logger.error(`${e.message}`);
182-
if (await window.showErrorMessage(e.message, `Open documentation`)) {
182+
if (await window.showErrorMessage(e.message, 'Open documentation')) {
183183
env.openExternal(link);
184184
}
185185
} else if (e instanceof Error) {

src/hlsBinaries.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,7 @@ async function callAsync(
133133

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

test/suite/extension.test.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ suite('Extension Test Suite', () => {
125125
vscode.window.showInformationMessage('Start all tests.');
126126

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

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

169-
test('HLS executables should be downloaded', async () => {
170-
await vscode.workspace.openTextDocument(getWorkspaceFile('Main.hs'));
171-
console.log('Testing wrapper');
172-
assert.ok(
173-
await withTimeout(90, filesCreated.get('wrapper')!),
174-
'The wrapper executable was not downloaded in 90 seconds'
175-
);
176-
console.log('Testing server');
177-
assert.ok(
178-
await withTimeout(90, filesCreated.get('server')!),
179-
'The server executable was not downloaded in 90 seconds'
180-
);
181-
});
182-
183161
test('Extension log should have server output', async () => {
184162
await vscode.workspace.openTextDocument(getWorkspaceFile('Main.hs'));
185163
await delay(20);

0 commit comments

Comments
 (0)