Skip to content

Improve some texts in CLion plugin #362

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

Merged
merged 4 commits into from
Aug 1, 2022
Merged
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
36 changes: 17 additions & 19 deletions clion-plugin/README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,52 @@
# UTBotCpp-CLion-plugin
<!-- Plugin description -->
Plugin for communication with UTBotCpp server in CLion.
Plugin to communicate with [UTBotCpp](https://github.com/UnitTestBot/UTBotCpp) server in CLion.

### Installation

1. Clone UTBotCpp and cd there and do:
1. Clone UTBotCpp into selected folder, select it in the command line and run:
```
cd clion-plugin
./gradlew assembleDist
```
2. Open CLion, go to settings -> plugins
2. Open CLion and go to `settings -> plugins`
3. Click `Install Plugin from Disk...`:
![](images/install/install-from-disk.png)
4. Navigate to plugin folder `clion-plugin`, then go to `build/distributions`
4. Navigate to plugin folder `clion-plugin`, go to `build/distributions`
and choose `zip` file:
![](images/install/choose-zip.png)
5. Restart CLion


### Configuration

#### Using quickstart wizard
When you open a plugin for the first time the quickstart wizard will appear.
When the plugin is opened for the first time, a quickstart wizard appears.

![](images/plugin_usage/wizard.png)

You can open it manually at any time by clicking on connection status and choosing
`Show Quickstart Wizard`.
You can open it manually any time: click on `connection status` and choose
`Show Quickstart Wizard` action.

![](images/plugin_usage/show_wizard.png)

Or you can do it by pressing `shift` twice and finding an action:
or press `shift` twice and find this action:


![](images/plugin_usage/find-wizard-action.png)

#### Using settings

You also can configure plugin manually in settings, where you will find
all configuration options.
You can also configure plugin using settings. All options can be set manually.

1. Open plugin settings in settings - Tools - UTBot Settings
2. Click `detect paths`. It will try to get source paths, build dir paths from CLion
CMake model.
3. Specify absolute path to build directory, it should be different from build directory that CLion uses,
because there can be conflicts between UTBotCpp and CLion. For example, if CLion uses `project_path/cmake-build-debug`,
then you can specify `project_path/utbot_build`.
1. Open plugin settings in `settings` - `Tools` - `UTBot Settings`
2. Click `detect paths`. It tries to get source paths and build directories paths from CLion
cmake model.
3. Specify an absolute path to the build directory, it should be different from the build directory that CLion uses,
because conflicts between UTBotCpp and CLion may occur. For example, if CLion uses `project_path/cmake-build-debug`,
you can specify `project_path/utbot_build`.
4. For target path specify `/utbot/auto/target/path`
5. Specify path to test folder.
6. Specify name of the server and port.
5. Specify a path to test folder.
6. Specify a name of the server and port.
7. If you use docker to run UTBotCpp and your project is mounted to docker,
you can specify path to project inside docker.

Expand Down
28 changes: 14 additions & 14 deletions clion-plugin/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,27 @@
# How to use plugin

### Check connection status
To use plugin you should be connected to server, you can check
the connection status in status bar:
You must be connected to server to use plugin. \
Connection status can be checked in the status bar.

![](images/plugin_usage/connectionStatus.png)

### Configure project and generate json files
For test generation to work your project must be configured by server.

Your project must be configured by server to generate tests.

To send request for project configuration or generation of json files
click on connection status in the status bar and choose suitable option:

To send request for project configuration or json files generation,
click on `connection status` in the status bar and choose a suitable option:

![](images/plugin_usage/generateJson.png)

Plugin sends request for project configuration when you open
the project. Sometimes configuration fails, and then after you changed
the project. Sometimes configuration fails, then after changing
your project you need to send the request for project configuration.

### Choose source folders

The server needs to know under what folders source files are.
To generate tests for project, server needs to know the folders source files are located in.
The source folders are marked with green icons in the project view:

![](images/plugin_usage/source-folders.png)
Expand All @@ -33,22 +32,23 @@ You can mark/unmark selected folders from context menu.
![](images/plugin_usage/mark-unmark-folders.gif)

### How to request tests generation
Open a c/cpp file, right click in the text editor and in context menu
choose suitable option:

Open a c/cpp file, right click in the text editor and
choose suitable option in the context menu:

![editor actions](images/plugin_usage/editorActions.png)

To generate tests for a folder right click on a folder in project view
For example, to generate tests for the folder, right click on it in the project view
and choose `Generate for folder`:

![project view actions](images/plugin_usage/projectViewActions.png)

### See logs from server and client
You can see what messages are sent to the server and server logging messages.
For that click on the `UTBot consoles` tab in the bottom right corner:

You can see messages that are sent to the server and server own logging messages. Just click on the `UTBot consoles` tab in the bottom right corner:

![UTBot consoles tab](images/plugin_usage/consolesTab.png)

add choose the needed tab:
add choose the required tab:

![UTBot consoles view](images/plugin_usage/consolesToolWindow.png)
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class GTestLogChannelImpl(project: Project): LogChannelImpl(project) {
override val name: String = "GTest Log"
override val logLevel: String = "TestLogLevel"

override val console: UTBotConsole = project.service<OutputProvider>().gtestOutputChannel.outputConsole
override val console: UTBotConsole = project.service<OutputProvider>().gTestOutputChannel.outputConsole

override suspend fun open(stub: TestsGenServiceGrpcKt.TestsGenServiceCoroutineStub): Flow<Testgen.LogEntry> =
stub.openGTestChannel(getLogChannelGrpcRequest(logLevel))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,9 @@ import com.intellij.coverage.CoverageFileProvider
* don't need this class but for compatibility with api this class must be implemented.
*/
class UTBotCoverageFileProvider : CoverageFileProvider {
override fun getCoverageDataFilePath(): String? {
return null
}
override fun getCoverageDataFilePath(): String? = null

override fun ensureFileExists(): Boolean {
return true
}
override fun ensureFileExists(): Boolean = true

override fun isValid(): Boolean {
return true
}
override fun isValid(): Boolean = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,14 @@ class UTBotCoverageRunner : CoverageRunner() {
return if (isAnyCoverage) projectData else null
}

override fun getPresentableName(): String {
return "UTBot: Coverage runner"
}
override fun getPresentableName(): String = "UTBot: Coverage runner"

override fun getId(): String {
return "UTBotCoverageRunner"
}
override fun getId(): String = "UTBotCoverageRunner"

// actually no coverage file exists, but this method must be implemented, see UTBotCoverageFileProvider
override fun getDataFileExtension(): String {
return "txt"
}
override fun getDataFileExtension(): String = "txt"

override fun acceptsCoverageEngine(engine: CoverageEngine): Boolean {
return engine is UTBotCoverageEngine
}
override fun acceptsCoverageEngine(engine: CoverageEngine): Boolean = engine is UTBotCoverageEngine

companion object {
fun provideQualifiedNameForFile(absolutePath: String) = absolutePath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import testsgen.Testgen
fun interface UTBotTestResultsReceivedListener {
companion object {
val TOPIC = Topic.create(
"UTBot settings changed",
"UTBot test results received",
UTBotTestResultsReceivedListener::class.java
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class UTBotAllProjectSettings(val project: Project) {
// so we should guess the project path
storedSettings.projectPath = project.guessProjectDir()?.path
return storedSettings.projectPath
?: error("Could not guess project path! Should be specified in settings by user")
?: error("Could not guess project path! Should be specified in settings")
}
set(value) {
storedSettings.projectPath = value
Expand All @@ -49,7 +49,7 @@ class UTBotAllProjectSettings(val project: Project) {

/**
* If this property returns true, plugin must convert path sent and returned from server.
* @see [String.convertToRemotePathIfNeeded], [String.convertFromRemotePathIfNeeded]
* @see [String.convertToRemotePathIfNeeded] and [String.convertFromRemotePathIfNeeded]
*
* If we are on Windows, this is not a server, so it is always a remote scenario.
*/
Expand All @@ -74,7 +74,7 @@ class UTBotAllProjectSettings(val project: Project) {
try {
storedSettings.testDirPath = Paths.get(projectPath, "tests").toString()
} catch (e: IllegalStateException) {
notifyWarning("Guessing settings failed: could not guess project path! Please specify project path in settings!")
notifyWarning("Guessing settings failed: could not guess project path! Please specify it in settings!")
}

val cmakeRunConfiguration = CMakeAppRunConfiguration.getSelectedConfigurationAndTarget(project)?.first
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("UnstableApiUsage")

package org.utbot.cpp.clion.plugin.settings

import com.intellij.openapi.diagnostic.Logger
Expand All @@ -22,7 +24,7 @@ import org.utbot.cpp.clion.plugin.utils.commandLineEditor
import java.awt.Dimension

class UTBotConfigurable(private val myProject: Project) : BoundConfigurable(
"Project Settings for Generating Tests"
"Project Settings to generate tests"
) {
private val logger = Logger.getInstance("ProjectConfigurable")
private val panel by lazy { createMainPanel() }
Expand All @@ -49,7 +51,7 @@ class UTBotConfigurable(private val myProject: Project) : BoundConfigurable(
}
}

fun createMainPanel(): DialogPanel {
private fun createMainPanel(): DialogPanel {
logger.trace("createPanel was called")
return panel {
group("Connection Settings") {
Expand All @@ -73,7 +75,7 @@ class UTBotConfigurable(private val myProject: Project) : BoundConfigurable(
myProject,
FileChooserDescriptorFactory.createSingleFileDescriptor()
).bindText(
getter = { myProject.settings.projectPath ?: "" },
getter = { myProject.settings.projectPath },
setter = { value -> myProject.settings.projectPath = value })
.columns(COLUMNS_LARGE)
}.rowComment(UTBot.message("settings.project.projectPath.info"))
Expand Down Expand Up @@ -110,7 +112,7 @@ class UTBotConfigurable(private val myProject: Project) : BoundConfigurable(
myProject.settings.predictPaths()
myProject.settings.fireUTBotSettingsChanged()
}
}.rowComment("Queries CMake configurations in order to get source paths, build path. Also predicts tests folder")
}.rowComment("Queries CMake configurations to get source paths and build path. Also predicts tests folder")
}

group("CMake") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import javax.swing.JPanel
@Service
class OutputProvider(val project: Project) : Disposable {
val clientOutputChannel: OutputChannel by lazy { createOutputChannel(OutputType.CLIENT_LOG) }
val gtestOutputChannel: OutputChannel by lazy { createOutputChannel(OutputType.GTEST_LOG) }
val gTestOutputChannel: OutputChannel by lazy { createOutputChannel(OutputType.GTEST_LOG) }
val serverOutputChannel: OutputChannel by lazy { createOutputChannel(OutputType.SERVER_LOG) }

data class OutputChannel(val uiComponent: Component, val outputConsole: UTBotConsole, val type: OutputType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ data class UTBotTarget(val path: String, val name: String, val description: Stri
val autoTarget = UTBotTarget(
path = "/utbot/auto/target/path",
name = "UTBot: auto",
description = "Finds any target that contains the code under testing"
description = "Finds any target that contains the code under test"
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ConsoleToolWindow(val project: Project) : SimpleToolWindowPanel(true, true
val provider = project.service<OutputProvider>()
for (channel in listOf(
provider.clientOutputChannel,
provider.gtestOutputChannel,
provider.gTestOutputChannel,
provider.serverOutputChannel
)) {
mainUI.addTab(channel.type.title, channel.uiComponent)
Expand Down