Skip to content

Commit

Permalink
Enable running Maestro on Windows without WSL (#2248)
Browse files Browse the repository at this point in the history
* Fix Windows script error by making classpath shorting using globs

* Update dadb

* Do not use emojis on Windows

* Fix Studio npm builds on Windows

* Make OS comparison case-insensitive

* Use smiley face instead of check

* Use + instead of special char

* Remove debug condition

---------

Co-authored-by: Dan Caseley <[email protected]>
  • Loading branch information
Leland-Takamine and Fishbowler authored Jan 16, 2025
1 parent 14f69eb commit c3a8027
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 17 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ axml = "2.1.2"
commons-codec = "1.17.0"
commons-lang3 = "3.13.0" # 3.14.0 causes weird crashes during dexing
commons-io = "2.16.1"
dadb = "1.2.7"
dadb = "1.2.9"
detekt = "1.19.0"
googleFindbugs = "3.0.2"
googleGson = "2.11.0"
Expand Down
4 changes: 4 additions & 0 deletions maestro-cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ tasks.named<JavaExec>("run") {
workingDir = rootDir
}

tasks.named<CreateStartScripts>("startScripts") {
classpath = files("$buildDir/libs/*")
}

dependencies {
implementation(project(path = ":maestro-utils"))
annotationProcessor(libs.picocli.codegen)
Expand Down
8 changes: 6 additions & 2 deletions maestro-cli/src/main/java/maestro/cli/command/TestCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import maestro.cli.runner.TestSuiteInteractor
import maestro.cli.runner.resultview.AnsiResultView
import maestro.cli.runner.resultview.PlainTextResultView
import maestro.cli.session.MaestroSessionManager
import maestro.cli.util.EnvUtils
import maestro.cli.util.FileUtils.isWebFlow
import maestro.cli.util.PrintUtils
import maestro.cli.view.box
Expand Down Expand Up @@ -353,8 +354,11 @@ class TestCommand : Callable<Int> {
debugOutputPath: Path,
): Triple<Int, Int, Nothing?> {
val resultView =
if (DisableAnsiMixin.ansiEnabled) AnsiResultView()
else PlainTextResultView()
if (DisableAnsiMixin.ansiEnabled) {
AnsiResultView(useEmojis = !EnvUtils.isWindows())
} else {
PlainTextResultView()
}

env = env
.withInjectedShellEnvVars()
Expand Down
3 changes: 2 additions & 1 deletion maestro-cli/src/main/java/maestro/cli/runner/TestRunner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import maestro.cli.report.TestDebugReporter
import maestro.cli.runner.resultview.AnsiResultView
import maestro.cli.runner.resultview.ResultView
import maestro.cli.runner.resultview.UiState
import maestro.cli.util.EnvUtils
import maestro.cli.util.PrintUtils
import maestro.cli.view.ErrorViewUtils
import maestro.orchestra.MaestroCommand
Expand Down Expand Up @@ -94,7 +95,7 @@ object TestRunner {
flowFile: File,
env: Map<String, String>,
): Nothing {
val resultView = AnsiResultView("> Press [ENTER] to restart the Flow\n\n")
val resultView = AnsiResultView("> Press [ENTER] to restart the Flow\n\n", useEmojis = !EnvUtils.isWindows())

val fileWatcher = FileWatcher()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import org.fusesource.jansi.Ansi
class AnsiResultView(
private val prompt: String? = null,
private val printCommandLogs: Boolean = true,
private val useEmojis: Boolean = true,
) : ResultView {

private val startTimestamp = System.currentTimeMillis()
Expand Down Expand Up @@ -248,18 +249,29 @@ class AnsiResultView(
return Frame(System.currentTimeMillis() - startTimestamp, content)
}

data class Frame(val timestamp: Long, val content: String)
}

internal fun status(status: CommandStatus): String {
return when (status) {
CommandStatus.COMPLETED -> ""
CommandStatus.FAILED -> ""
CommandStatus.RUNNING -> ""
CommandStatus.PENDING -> "\uD83D\uDD32 " // 🔲
CommandStatus.WARNED -> "⚠️ "
CommandStatus.SKIPPED -> "⚪️ "
private fun status(status: CommandStatus): String {
if (useEmojis) {
return when (status) {
CommandStatus.COMPLETED -> ""
CommandStatus.FAILED -> ""
CommandStatus.RUNNING -> ""
CommandStatus.PENDING -> "\uD83D\uDD32 " // 🔲
CommandStatus.WARNED -> "⚠️ "
CommandStatus.SKIPPED -> "⚪️ "
}
} else {
return when (status) {
CommandStatus.COMPLETED -> "+ "
CommandStatus.FAILED -> "X "
CommandStatus.RUNNING -> "> "
CommandStatus.PENDING -> " "
CommandStatus.WARNED -> "! "
CommandStatus.SKIPPED -> "- "
}
}
}

data class Frame(val timestamp: Long, val content: String)
}

// Helper launcher to play around with presentation
Expand Down
4 changes: 4 additions & 0 deletions maestro-cli/src/main/java/maestro/cli/util/EnvUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ object EnvUtils {
return false
}

fun isWindows(): Boolean {
return OS_NAME.lowercase().startsWith("windows")
}

/**
* Returns major version of Java, e.g. 8, 11, 17, 21.
*/
Expand Down
12 changes: 10 additions & 2 deletions maestro-studio/web/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
tasks.register("deps", Exec.class) {
inputs.file(layout.projectDirectory.file("package.json"))
outputs.dir(layout.projectDirectory.dir("node_modules"))
commandLine("npm", "install")
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
commandLine 'npm.cmd', 'install'
} else {
commandLine 'npm', 'install'
}
}

tasks.register("build", Exec.class) {
Expand All @@ -11,5 +15,9 @@ tasks.register("build", Exec.class) {
inputs.files(inputFiles)
outputs.dir(layout.projectDirectory.dir("build"))
dependsOn(tasks.deps)
commandLine("npm", "run", "build")
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
commandLine 'npm.cmd', 'run', 'build'
} else {
commandLine("npm", "run", "build")
}
}

0 comments on commit c3a8027

Please sign in to comment.