diff --git a/CHANGES_CURRENT.md b/CHANGES_CURRENT.md index da257f655f..ba34f5ae11 100644 --- a/CHANGES_CURRENT.md +++ b/CHANGES_CURRENT.md @@ -4,6 +4,8 @@ ### Bug Fixes +- #3289 - Extensions: Fix logs location path provided to extension (related #3268) + ### Performance ### Documentation diff --git a/development_extensions/oni-test-extension/extension.js b/development_extensions/oni-test-extension/extension.js index 59d3ff6f81..0ba75ba99b 100644 --- a/development_extensions/oni-test-extension/extension.js +++ b/development_extensions/oni-test-extension/extension.js @@ -1,6 +1,7 @@ // The module 'vscode' contains the VS Code extensibility API // Import the module and reference it with the alias vscode in your code below const vscode = require("vscode") +const path = require("path"); /** * @param {vscode.ExtensionContext} context @@ -13,6 +14,33 @@ function activate(context) { vscode.window.showInformationMessage(message, []) }), ); + + + const pass = () => { + vscode.window.showInformationMessage("PASS", []) + }; + + const fail = (msg) => { + vscode.window.showInformationMessage("FAIL: " + msg, []) + }; + + cleanup( + vscode.commands.registerCommand("oni-test.exthost.validateLogPathIsDirectory", () => { + (async () => { + // From docs: https://code.visualstudio.com/api/references/vscode-api#ExtensionContext + // Given path might not exist - but parent directory will exist. + const logPath = path.dirname(context.logUri.path); + const logParentUri = vscode.Uri.file(logPath); + const statResult = await vscode.workspace.fs.stat(logParentUri); + + if ((statResult.type & vscode.FileType.Directory) == vscode.FileType.Directory) { + pass() + } else { + fail("Filetype was: " + statResult.type.toString()); + } + })(); + }), + ); } // this method is called when your extension is deactivated diff --git a/development_extensions/oni-test-extension/package.json b/development_extensions/oni-test-extension/package.json index bd535dd6db..efb8bd7445 100644 --- a/development_extensions/oni-test-extension/package.json +++ b/development_extensions/oni-test-extension/package.json @@ -7,7 +7,8 @@ "vscode": "^1.25.0" }, "activationEvents": [ - "onCommand:oni-test.showMessage" + "onCommand:oni-test.showMessage", + "onCommand:oni-test.exthost.validateLogPathIsDirectory" ], "main": "./extension.js", "contributes": {}, diff --git a/integration_test/ExtHostContextTest.re b/integration_test/ExtHostContextTest.re new file mode 100644 index 0000000000..a4e0c9bde8 --- /dev/null +++ b/integration_test/ExtHostContextTest.re @@ -0,0 +1,46 @@ +open Oni_Model; +open Oni_IntegrationTestLib; + +// This test validates: +// - The 'oni-dev' extension gets activated +// - When typing in an 'oni-dev' buffer, we get some completion results +runTest(~name="ExtHostContextTest", ({dispatch, wait, _}) => { + wait(~timeout=30.0, ~name="Exthost is initialized", (state: State.t) => + Feature_Exthost.isInitialized(state.exthost) + ); + + // Wait until the extension is activated + // Give some time for the exthost to start + wait( + ~timeout=30.0, + ~name="Validate the 'oni-dev' extension gets activated", + (state: State.t) => + List.exists( + id => id == "oni-dev-extension", + state.extensions |> Feature_Extensions.activatedIds, + ) + ); + + // Kick off an oni-test command that should activate the oni-test-extension: + dispatch( + Actions.Extensions( + Feature_Extensions.Msg.command( + ~command="oni-test.exthost.validateLogPathIsDirectory", + ~arguments=[], + ), + ), + ); + + // Validate test passes + wait( + ~timeout=30.0, + ~name="Validate test passes", + (state: State.t) => { + let notifications = Feature_Notification.all(state.notifications); + notifications + |> List.exists((notification: Feature_Notification.notification) => { + notification.message == "PASS" + }); + }, + ); +}); diff --git a/integration_test/dune b/integration_test/dune index 564cf55e6d..6048225422 100644 --- a/integration_test/dune +++ b/integration_test/dune @@ -6,7 +6,7 @@ ConfigurationInvalidThemeTest ConfigurationPerFileTypeTest EditorFontFromPathTest EditorFontValidTest EditorSplitFileTest EditorUtf8Test ExCommandKeybindingTest ExCommandKeybindingWithArgsTest - ExCommandKeybindingNormTest ExtConfigurationChangedTest + ExCommandKeybindingNormTest ExtConfigurationChangedTest ExtHostContextTest ExtHostBufferOpenTest ExtHostBufferUpdatesTest ExtHostCommandActivationTest ExtHostCompletionTest ExtHostDefinitionTest ExtHostWorkspaceSearchTest FileWatcherTest FormatOnSaveTest @@ -44,7 +44,7 @@ ExCommandKeybindingNormTest.exe ExCommandKeybindingWithArgsTest.exe ExtConfigurationChangedTest.exe ExtHostBufferOpenTest.exe ExtHostBufferUpdatesTest.exe ExtHostCommandActivationTest.exe - ExtHostCompletionTest.exe ExtHostDefinitionTest.exe + ExtHostContextTest.exe ExtHostCompletionTest.exe ExtHostDefinitionTest.exe ExtHostWorkspaceSearchTest.exe FileWatcherTest.exe FormatOnSaveTest.exe KeybindingsInvalidJsonTest.exe KeySequenceJJTest.exe InputIgnoreTest.exe InputContextKeysTest.exe InputRemapMotionTest.exe LanguageCssTest.exe diff --git a/src/Store/ExtensionClient.re b/src/Store/ExtensionClient.re index e1cad438fb..331d5d5e1d 100644 --- a/src/Store/ExtensionClient.re +++ b/src/Store/ExtensionClient.re @@ -248,8 +248,8 @@ let create = let tempDir = Filename.get_temp_dir_name(); - let logFile = tempDir |> Uri.fromPath; - let logsLocation = + let logsLocation = tempDir |> Uri.fromPath; + let logFile = Filename.temp_file(~temp_dir=tempDir, "onivim2", "exthost.log") |> Uri.fromPath;