Skip to content

Commit

Permalink
test: fix failing tests due to colliding file names
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-reimann committed Sep 20, 2023
1 parent 48b5f53 commit ea3cf0f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
File renamed without changes.
8 changes: 4 additions & 4 deletions src/language/safe-ds-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import {
PartialLangiumServices,
} from 'langium';
import { SafeDsGeneratedModule, SafeDsGeneratedSharedModule } from './generated/module.js';
import { SafeDsValidator, registerValidationChecks } from './validation/safe-ds-validator.js';
import { registerValidationChecks, SafeDsValidator } from './validation/safe-ds-validator.js';
import { SafeDsFormatter } from './formatting/safe-ds-formatter.js';
import { SafeDsWorkspaceManager } from './builtins/workspaceManager.js';
import {SafeDsScopeComputation} from "./scoping/safe-ds-scope-computation.js";
import {SafeDsScopeProvider} from "./scoping/safe-ds-scope-provider.js";
import { SafeDsWorkspaceManager } from './builtins/safe-ds-workspace-manager.js';
import { SafeDsScopeComputation } from './scoping/safe-ds-scope-computation.js';
import { SafeDsScopeProvider } from './scoping/safe-ds-scope-provider.js';

/**
* Declaration of custom services - add your own service classes here.
Expand Down
6 changes: 5 additions & 1 deletion tests/helpers/diagnostics.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { validationHelper } from 'langium/test';
import { clearDocuments, validationHelper } from 'langium/test';
import { LangiumServices } from 'langium';
import { Diagnostic, DiagnosticSeverity } from 'vscode-languageserver-types';

Expand All @@ -11,6 +11,10 @@ import { Diagnostic, DiagnosticSeverity } from 'vscode-languageserver-types';
*/
export const getSyntaxErrors = async (services: LangiumServices, code: string): Promise<Diagnostic[]> => {
const validationResult = await validationHelper(services)(code);

// Clear loaded documents to avoid colliding URIs (https://github.com/langium/langium/issues/1146)
await clearDocuments(services);

return validationResult.diagnostics.filter(
(d) =>
d.severity === DiagnosticSeverity.Error &&
Expand Down
8 changes: 7 additions & 1 deletion tests/language/builtins/workspaceManager.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { beforeAll, describe, expect, it } from 'vitest';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
import { listBuiltinsFiles } from '../../../src/language/builtins/workspaceManager.js';
import { createSafeDsServices } from '../../../src/language/safe-ds-module.js';
import { getLinkingErrors } from '../../helpers/diagnostics.js';
import { NodeFileSystem } from 'langium/node';
import { clearDocuments } from 'langium/test';

const services = createSafeDsServices(NodeFileSystem).SafeDs;

Expand All @@ -29,6 +30,11 @@ class C {
},
);
});

afterAll(async () => {
// Clear loaded documents to avoid colliding URIs (https://github.com/langium/langium/issues/1146)
await clearDocuments(services);
});
});

describe('listBuiltinsFiles', () => {
Expand Down

0 comments on commit ea3cf0f

Please sign in to comment.