Skip to content

Commit fc21e89

Browse files
feat: Redirecting outputs of intellij instance process improvements (#215)
* feat: Redirect intellij process outputs to user.dir Signed-off-by: Richard Kocian <[email protected]> rh-pre-commit.version: 2.2.0 rh-pre-commit.check-secrets: ENABLED * feat: Redirecting intellij process outputs depends on intellij_debug property Signed-off-by: Richard Kocian <[email protected]> rh-pre-commit.version: 2.2.0 rh-pre-commit.check-secrets: ENABLED * feat: Redirect intellij process outputs in test-project Signed-off-by: Richard Kocian <[email protected]> rh-pre-commit.version: 2.2.0 rh-pre-commit.check-secrets: ENABLED * docs: Added info about intellij_debug Signed-off-by: Richard Kocian <[email protected]> rh-pre-commit.version: 2.2.0 rh-pre-commit.check-secrets: ENABLED
1 parent 52884ce commit fc21e89

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@ systemProperties['testProjectLocation'] = project.hasProperty('testProjectLocati
8181
./gradlew integrationTest -PtestProjectLocation=${env.HOME}/IdeaProjects/intellij-ui-test-projects/
8282
```
8383

84+
### Remote-robot IntelliJ instance logs
85+
If developers want to view the remote-robot intellij instance logs, they can specify system property intellij_debug to save these logs to files, which will be stored inside $user.dir/intellij_debug folder.
86+
```
87+
task integrationTest(type: Test) {
88+
...
89+
systemProperties['intellij_debug'] = 'true'
90+
...
91+
}
92+
```
93+
8494
## Start and quit IntelliJ IDEA
8595
Use the following code to start IntelliJ before running the first UI test. The runIde() method not only starts the IDE for UI tests, it also returns reference to the Remote-Robot instance which will be useful later to access UI elements such as buttons, inputs etc.
8696
```

src/main/java/com/redhat/devtools/intellij/commonuitest/UITestRunner.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ public static RemoteRobot runIde(IntelliJVersion ideaVersion, int port) {
7878

7979
String fileExtension = OS_NAME.contains("windows") ? ".bat" : "";
8080
ProcessBuilder pb = new ProcessBuilder("." + File.separator + "gradlew" + fileExtension, "runIdeForUiTests", "-PideaVersion=" + ideaVersion, "-Drobot-server.port=" + port);
81-
redirectProcessOutputs(pb);
81+
82+
boolean isDebugOn = Boolean.parseBoolean(System.getProperty("intellij_debug", "false")); // For more info on intellij_debug please check README
83+
if (isDebugOn) {
84+
redirectProcessOutputs(pb);
85+
}
8286

8387
try {
8488
ideProcess = pb.start();
@@ -316,10 +320,10 @@ private static void copyFileFromJarResourceDir(String sourceFileLocation, String
316320
* @param pb Process builder of running subprocess
317321
*/
318322
private static void redirectProcessOutputs(ProcessBuilder pb) {
319-
String outDir = System.getProperty("user.home") + File.separator + "IntelliJ_debug";
323+
String outDir = System.getProperty("user.dir") + File.separator + "intellij_debug";
320324

321325
if (!new File(outDir).mkdirs()) {
322-
LOGGER.log(Level.SEVERE, "Cannot create user.home/debug directory");
326+
LOGGER.log(Level.SEVERE, "Cannot create user.dir/intellij_debug directory");
323327
}
324328

325329
File stdoutLog = new File(outDir + File.separator + "stdout.log");

src/test-project/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ patchPluginXml {
3131
}
3232

3333
test {
34+
systemProperties['intellij_debug'] = 'true'
3435
useJUnitPlatform()
3536
}

0 commit comments

Comments
 (0)