Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

publishBeforeTest is not triggering #30

Closed
bjarkihall opened this issue Dec 21, 2020 · 8 comments
Closed

publishBeforeTest is not triggering #30

bjarkihall opened this issue Dec 21, 2020 · 8 comments

Comments

@bjarkihall
Copy link
Contributor

Hi,

I'm finally giving the extension another try but the "al-test-runner.publishBeforeTest" setting doesn't seem to be respected,

I've tried "Publish" and "Rapid application publish" without any effect - running a test (procedure, codeunit and all tests) works but it doesn't pick up changes in code which indicates nothing was ever published.

I'm running the latest version of AL Test Runner (0.4.3) in VSCode (1.52.1) with AL Language (6.1.381) for BC 17.2 with BCContainerHelper (1.0.16).

Please let me know if I can provide you with more info, I'd love to be able to help.

@jimmymcp
Copy link
Owner

Hi,

I've only seen that when the app fails to compile. I assume that you can compile and publish without any problem?

@bjarkihall
Copy link
Contributor Author

bjarkihall commented Dec 22, 2020

Yes, I can use both rapid and normal publish via the command palette. I've taken a look at the source and it doesn't seem like anything has changed in MS's end - the names of the commands are the same.

I tried it again with only my project loaded and publishBeforeTest works - it seems like multi-root workspaces are somehow disabling this feature.

I also tried preTestCommand but it doesn't seem to output anything to the console in the multi-root workspace, so I'm guessing this line isn't getting any config from my .vscode/settings.json in the current workspace:

const config = vscode.workspace.getConfiguration('al-test-runner');

@bjarkihall
Copy link
Contributor Author

Should config.publishBeforeTest maybe be config.get('publishBeforeTest') ? (workspaces API)

@jimmymcp
Copy link
Owner

I'm assuming you've got two apps in the workspace, Test and Prod, Test depends on Prod?

It may be that Test is being published, but not Prod. I haven't investigated but that's what I'm seeing. That used to work but seems not to in the latest version of VS Code and/or AL Language.

@bjarkihall
Copy link
Contributor Author

I've actually been trying this with 3 apps - prod, test and a third one that's just an independent app - just in case the dependencies were causing the issue. It doesn't seem this is strictly caused by the AL Language extension but the extensibility API of vscode.

I haven't debugged this with breakpoints but vscode.workspace.getConfiguration seems to return a WorkspaceConfiguration object which exposes the properties via the get method - I'm guessing once you're in a multiroot workspace all properties you try to retrieve via dot-notation give you the undefined value.

Could that be the issue?

@jimmymcp
Copy link
Owner

I don't know. I've just been testing with different combinations of settings for the user, workspace and both. Everything that I have tried has worked as expected 🤔

@bjarkihall
Copy link
Contributor Author

I finally managed to clone the repo and debug, turns out the getConfiguration just picks the first workspaceFolder in a multi-root workspace (vscode.workspace.workspaceFolders is an array of them and the first one seems to be picked by default: vscode.workspace.workspaceFolders[0].uri).

getConfiguration has a second parameter to define the scope more narrowly and it turns out this line retrieves the value correctly (in my case, vscode.workspace.getWorkspaceFolder(vscode.window.activeTextEditor.document.uri).index === 2):

vscode.workspace.getConfiguration('al-test-runner', vscode.window.activeTextEditor.document.uri).publishBeforeTest

@bjarkihall
Copy link
Contributor Author

Looks like you've already had to deal with this one, since you have a function called getWorkspaceFolder.
I did this change and packed into a utility function which seems to be the general pattern I saw in the extension file:

vscode.workspace.getConfiguration('al-test-runner', vscode.Uri.file(getWorkspaceFolder()));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants