Skip to content

Commit

Permalink
Update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
petervdonovan committed Jun 22, 2023
1 parent 243f377 commit 4a789cd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
7 changes: 4 additions & 3 deletions src/check_dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ export const watcherConfig: CheckSet[] = [
},
];

export const caveat = 'If this dependency is already on your system, start VS Code from a terminal emulator so that VS Code sees the same value of your PATH that you see in your terminal.'

/**
* Return a dependency checker that returns whether the given dependency is satisfied and, as a side
* effect, warns the user if not.
Expand All @@ -277,11 +279,10 @@ const checkDependency: UserFacingVersionCheckerMaker = (dependency: DependencyIn
(MessageDisplayHelper: MessageDisplayHelper) => async () => {
const checkerResult: versionChecker.VersionCheckResult = await dependency.checker();
if (checkerResult.isCorrect) return true;
const caveat = "If this dependency is already on your system, start VS Code from a terminal emulator so that VS Code sees the same value of your PATH that you see in your terminal."
const message: string = (await (checkerResult.isCorrect === false ? (
dependency.wrongVersionMessage?.(checkerResult)
?? dependency.message(checkerResult)
) : dependency.message(checkerResult))) + "\n" + caveat;
) : dependency.message(checkerResult))) + ' ' + caveat;
const installCommand: InstallCommand = await dependency.installCommand?.(checkerResult);
if (!installCommand && !dependency.installLink) {
MessageDisplayHelper(message);
Expand Down Expand Up @@ -321,7 +322,7 @@ export const checkerFor: CheckerGetter = (name: Dependency) => {
};

const doDependencyCheck = (document: vscode.TextDocument) => {
if (document.languageId != "lflang") return;
if (document.languageId != 'lflang') return;
for (const checkSet of watcherConfig.filter(it => it.regexp.test(document.getText()))) {
for (const check of checkSet.checks.filter(
it => !it.alreadyChecked || (it.isEssential && !it.satisfied))
Expand Down
16 changes: 8 additions & 8 deletions src/test/check_dependencies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as vscode from 'vscode';
import chai from 'chai';
import spies from 'chai-spies';
import { expect } from 'chai';
import { after, Context } from 'mocha';
import { after } from 'mocha';
import { MessageDisplayHelper } from '../utils';
import * as http from 'http';
import * as url from 'url';
Expand Down Expand Up @@ -60,7 +60,7 @@ suite('test dependency checking', () => {
this.test.skip();
case DependencyStatus.Missing0:
await expectFailure(dependency, spy);
expect(spy).to.have.been.called.with(depMissingMessage);
expect(spy).to.have.been.called.with(depMissingMessage + " " + checkDependencies.caveat);
break;
case DependencyStatus.Missing1:
this.test.skip();
Expand Down Expand Up @@ -96,7 +96,7 @@ suite('test dependency checking', () => {
this.test.skip();
case DependencyStatus.Missing1:
await expectFailure(Dependency.Pylint, spy);
expect(spy).to.have.been.called.with(checkDependencies.pylintMessage);
expect(spy).to.have.been.called.with(checkDependencies.pylintMessage + " " + checkDependencies.caveat);
await new Promise(resolve => setTimeout(resolve, maxInstallationTimeMilliseconds));
await expectSuccess(Dependency.Pylint, spy);
break;
Expand All @@ -105,7 +105,7 @@ suite('test dependency checking', () => {
expect(spy).to.have.been.called.with(
`The Lingua Franca language server is tested with Pylint version `
+ `${config.pylintVersion.major}.${config.pylintVersion.minor} and newer, but `
+ `the version detected on your system is 2.10.0.`
+ `the version detected on your system is 2.10.0. ${checkDependencies.caveat}`
);
await new Promise(resolve => setTimeout(resolve, maxInstallationTimeMilliseconds));
await expectSuccess(Dependency.Pylint, spy);
Expand All @@ -126,13 +126,13 @@ suite('test dependency checking', () => {
break;
case DependencyStatus.Missing0:
await expectFailure(Dependency.Pnpm, spy);
expect(spy).to.have.been.called.with(checkDependencies.pnpmMessage);
expect(spy).to.have.been.called.with(checkDependencies.pnpmMessage + " " + checkDependencies.caveat);
break;
case DependencyStatus.Missing1:
await expectFailure(Dependency.Pnpm, spy);
expect(spy).to.have.been.called.with(
'To prevent an accumulation of replicated dependencies when compiling LF programs '
+ 'with the TypeScript target, it is highly recommended to install pnpm globally.'
+ 'with the TypeScript target, it is highly recommended to install pnpm globally.' + " " + checkDependencies.caveat
);
await new Promise(resolve => setTimeout(resolve, maxInstallationTimeMilliseconds));
await expectSuccess(Dependency.Pnpm, spy);
Expand All @@ -158,7 +158,7 @@ suite('test dependency checking', () => {
break;
case DependencyStatus.Missing0:
await expectFailure(Dependency.Rust, spy);
expect(spy).to.have.been.called.with(checkDependencies.rustMessage);
expect(spy).to.have.been.called.with(checkDependencies.rustMessage + " " + checkDependencies.caveat);
break;
case DependencyStatus.Missing1:
this.test.skip();
Expand All @@ -180,7 +180,7 @@ suite('test dependency checking', () => {
this.test.skip();
case DependencyStatus.Missing1:
await expectFailure(Dependency.Rti, spy);
expect(spy).to.have.been.called.with(checkDependencies.rtiMessage);
expect(spy).to.have.been.called.with(checkDependencies.rtiMessage + " " + checkDependencies.caveat);
break;
default:
throw new Error('unreachable');
Expand Down
2 changes: 1 addition & 1 deletion src/version_checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const rtiVersionChecker = async () => {
// TODO: Update when #76 is addressed: https://github.com/lf-lang/reactor-c/issues/76
let exists: boolean;
try {
exists = (await which("RTI")).length > 0;
exists = (await which('RTI')).length > 0;
} catch (e) {
return { version: new Version('0.0.0'), isCorrect: null };
}
Expand Down

0 comments on commit 4a789cd

Please sign in to comment.