Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ public CompletableFuture<List<FoldingRange>> foldingRange(FoldingRangeRequestPar

@Override
public void registerLanguage(LanguageParameter lang) {
logger.info("registerLanguage({})", lang.getName());
logger.info("registerLanguage({})/begin", lang.getName());

for (var extension: lang.getExtensions()) {
this.registeredExtensions.put(extension, lang.getName());
Expand Down Expand Up @@ -647,6 +647,8 @@ public void registerLanguage(LanguageParameter lang) {
if (client != null) {
fact.setClient(client);
}

logger.info("registerLanguage({})/end", lang.getName());
}

private static String buildContributionKey(LanguageParameter lang) {
Expand All @@ -655,6 +657,7 @@ private static String buildContributionKey(LanguageParameter lang) {

@Override
public void unregisterLanguage(LanguageParameter lang) {
logger.info("unregisterLanguage({})/begin", lang.getName());
boolean removeAll = lang.getMainModule() == null || lang.getMainModule().isEmpty();
if (!removeAll) {
if (!contributions.get(lang.getName()).removeContributor(buildContributionKey(lang))) {
Expand All @@ -676,6 +679,7 @@ public void unregisterLanguage(LanguageParameter lang) {
facts.remove(lang.getName());
contributions.remove(lang.getName());
}
logger.info("unregisterLanguage({})/end", lang.getName());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ Register the Pico language and the contributions that supply the IDE with featur
* You can run each contribution on an example in the terminal to test it first.
Any feedback (errors and exceptions) is faster and more clearly printed in the terminal.
}
void main() {
void main(bool unregister = false) {
if (unregister) {
unregisterLanguage("Pico", {"pico", "pico-new"});
}
registerLanguage(
language(
pathConfig(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Copyright (c) 2018-2025, NWO-I CWI and Swat.engineering
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

import { VSBrowser, WebDriver, Workbench } from 'vscode-extension-tester';
import { Delays, IDEOperations, RascalREPL, TestWorkspace, ignoreFails, printRascalOutputOnFailure } from './utils';

describe('DSL unregister/register race', function () {
let browser: VSBrowser;
let driver: WebDriver;
let bench: Workbench;
let ide : IDEOperations;

this.timeout(Delays.extremelySlow * 2);

printRascalOutputOnFailure('Language Parametric Rascal');

async function loadPico() {
const repl = new RascalREPL(bench, driver);
await repl.start();
await repl.execute("import demo::lang::pico::OldStyleLanguageServer;");
const replExecuteMain = repl.execute("main(unregister=true);"); // we don't wait yet, because we might miss pico loading window
const ide = new IDEOperations(browser);
const isPicoLoading = ide.statusContains("Pico");
await driver.wait(isPicoLoading, Delays.slow, "Pico DSL should start loading");
// now wait for the Pico loader to disappear
await driver.wait(async () => !(await isPicoLoading()), Delays.extremelySlow, "Pico DSL should be finished starting", 100);
await replExecuteMain;
await repl.terminate();
}

before(async () => {
browser = VSBrowser.instance;
driver = browser.driver;
bench = new Workbench();
await ignoreFails(browser.waitForWorkbench());
ide = new IDEOperations(browser);
await ide.load();
});

beforeEach(async function () {
await loadPico();
});

afterEach(async function () {
if (this.currentTest && this.currentTest.state === 'failed') {
throw Error('Race successfully triggered');
}
await ide.cleanup();
});

after(async function() {
});

for (let i = 0; i < 100; i++) {
it.only("Try trigger race", async function () {
const editor = await ide.openModule(TestWorkspace.picoFile);
await ide.hasSyntaxHighlighting(editor);
await ide.hasInlayHint(editor);
});
}
});

5 changes: 3 additions & 2 deletions runUItests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ rm -rf $UITESTS || true
npm run compile-tests

# test what was compiled

VSCODE_VERSION=`grep '"vscode":' package.json | awk -F\^ '{ print $2 }' | awk -F\" '{ print $1 }'`
echo "Running tests with VSCode version $VSCODE_VERSION"
exec npx extest setup-and-run out/test/vscode-suite/*.test.js \
--code_version 1.82.3 \
--code_version ${VSCODE_VERSION} \
--storage $UITESTS \
--extensions_dir $UITESTS/extensions_dir
Loading