Skip to content

Commit 269f73d

Browse files
committed
.
1 parent 451ec65 commit 269f73d

File tree

5 files changed

+53
-51
lines changed

5 files changed

+53
-51
lines changed

os/src/ProcessOps.scala

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ object call {
1313
* @see [[os.proc.call]]
1414
*/
1515
def apply(
16-
cmd: Shellable,
17-
env: Map[String, String] = null,
18-
// Make sure `cwd` only comes after `env`, so `os.call("foo", path)` is a compile error
19-
// since the correct syntax is `os.call(("foo", path))`
20-
cwd: Path = null,
21-
stdin: ProcessInput = Pipe,
22-
stdout: ProcessOutput = Pipe,
23-
stderr: ProcessOutput = os.Inherit,
24-
mergeErrIntoOut: Boolean = false,
25-
timeout: Long = -1,
26-
check: Boolean = true,
27-
propagateEnv: Boolean = true,
28-
shutdownGracePeriod: Long = 100,
29-
shutdownHook: Boolean = false
16+
cmd: Shellable,
17+
env: Map[String, String] = null,
18+
// Make sure `cwd` only comes after `env`, so `os.call("foo", path)` is a compile error
19+
// since the correct syntax is `os.call(("foo", path))`
20+
cwd: Path = null,
21+
stdin: ProcessInput = Pipe,
22+
stdout: ProcessOutput = Pipe,
23+
stderr: ProcessOutput = os.Inherit,
24+
mergeErrIntoOut: Boolean = false,
25+
timeout: Long = -1,
26+
check: Boolean = true,
27+
propagateEnv: Boolean = true,
28+
shutdownGracePeriod: Long = 100,
29+
shutdownHook: Boolean = false
3030
): CommandResult = {
3131
os.proc(cmd).call(
3232
cwd = cwd,
@@ -186,18 +186,18 @@ case class proc(command: Shellable*) {
186186
* issued. Check the documentation for your JDK's `Process.destroy`.
187187
*/
188188
def call(
189-
cwd: Path = null,
190-
env: Map[String, String] = null,
191-
stdin: ProcessInput = Pipe,
192-
stdout: ProcessOutput = Pipe,
193-
stderr: ProcessOutput = os.Inherit,
194-
mergeErrIntoOut: Boolean = false,
195-
timeout: Long = -1,
196-
check: Boolean = true,
197-
propagateEnv: Boolean = true,
198-
// this cannot be next to `timeout` as this will introduce a bin-compat break (default arguments are numbered in the bytecode)
199-
shutdownGracePeriod: Long = 100,
200-
shutdownHook: Boolean = false
189+
cwd: Path = null,
190+
env: Map[String, String] = null,
191+
stdin: ProcessInput = Pipe,
192+
stdout: ProcessOutput = Pipe,
193+
stderr: ProcessOutput = os.Inherit,
194+
mergeErrIntoOut: Boolean = false,
195+
timeout: Long = -1,
196+
check: Boolean = true,
197+
propagateEnv: Boolean = true,
198+
// this cannot be next to `timeout` as this will introduce a bin-compat break (default arguments are numbered in the bytecode)
199+
shutdownGracePeriod: Long = 100,
200+
shutdownHook: Boolean = false
201201
): CommandResult = {
202202

203203
val chunks = new java.util.concurrent.ConcurrentLinkedQueue[Either[geny.Bytes, geny.Bytes]]
@@ -327,7 +327,7 @@ case class proc(command: Shellable*) {
327327
override def run(): Unit = {
328328
while (proc.wrapped.isAlive) Thread.sleep(1)
329329
try Runtime.getRuntime().removeShutdownHook(t)
330-
catch{case e: Throwable => /*do nothing*/}
330+
catch { case e: Throwable => /*do nothing*/ }
331331
}
332332
}
333333
)

os/src/SubProcess.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@ class SubProcess(
157157
* (i.e. force exit immediately) or Long.MaxValue (i.e. never force exit)
158158
* or anything in between. Typically defaults to 100 milliseconds
159159
*/
160-
def destroy(shutdownGracePeriod: Long = this.shutdownGracePeriod, async: Boolean = false): Unit = {
160+
def destroy(
161+
shutdownGracePeriod: Long = this.shutdownGracePeriod,
162+
async: Boolean = false
163+
): Unit = {
161164
wrapped.destroy()
162165
if (!async) {
163166
val now = System.currentTimeMillis()

os/test/src-jvm/SpawningSubprocessesNewTests.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ object SpawningSubprocessesNewTests extends TestSuite {
153153
sha.stdout.trim() ==> s"${ExampleResourcess.RemoteReadme.gzip6ShaSum256} -"
154154
}
155155
}
156-
test("spawn callback") - prep { wd =>
156+
test("spawn callback") - prep { wd =>
157157
if (TestUtil.isInstalled("echo") && Unix()) {
158158
val output: mutable.Buffer[String] = mutable.Buffer()
159159
val sub = os.spawn(
@@ -174,16 +174,16 @@ object SpawningSubprocessesNewTests extends TestSuite {
174174
.open(p.toNIO, util.EnumSet.of(StandardOpenOption.READ, StandardOpenOption.WRITE))
175175
.tryLock()
176176
def waitForLockTaken(p: os.Path) = {
177-
while({
177+
while ({
178178
val waitLock = tryLock(p)
179179
if (waitLock != null) {
180180
waitLock.release()
181181
true
182-
}else false
182+
} else false
183183
}) Thread.sleep(1)
184184
}
185185

186-
test("destroy"){
186+
test("destroy") {
187187
val temp1 = os.temp()
188188
val sub1 = os.spawn((sys.env("TEST_SPAWN_EXIT_HOOK_ASSEMBLY"), temp1))
189189
waitForLockTaken(temp1)
@@ -197,8 +197,7 @@ object SpawningSubprocessesNewTests extends TestSuite {
197197
assert(sub2.isAlive())
198198
}
199199

200-
test("spawnExitHook"){
201-
200+
test("spawnExitHook") {
202201

203202
val temp = os.temp()
204203
val lock0 = tryLock(temp)

os/test/src-jvm/SpawningSubprocessesTests.scala

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -147,23 +147,23 @@ object SpawningSubprocessesTests extends TestSuite {
147147
}
148148
}
149149
test("spawn callback") {
150-
test - prep { wd =>
151-
if (TestUtil.isInstalled("echo") && Unix()) {
152-
val output: mutable.Buffer[String] = mutable.Buffer()
153-
val sub = os.proc("echo", "output")
154-
.spawn(stdout =
155-
ProcessOutput((bytes, count) => output += new String(bytes, 0, count))
156-
)
157-
val finished = sub.join(5000)
158-
sub.wrapped.getOutputStream().flush()
159-
assert(finished)
160-
assert(sub.exitCode() == 0)
161-
val expectedOutput = "output\n"
162-
val actualOutput = output.mkString("")
163-
assert(actualOutput == expectedOutput)
164-
sub.destroy()
165-
}
150+
test - prep { wd =>
151+
if (TestUtil.isInstalled("echo") && Unix()) {
152+
val output: mutable.Buffer[String] = mutable.Buffer()
153+
val sub = os.proc("echo", "output")
154+
.spawn(stdout =
155+
ProcessOutput((bytes, count) => output += new String(bytes, 0, count))
156+
)
157+
val finished = sub.join(5000)
158+
sub.wrapped.getOutputStream().flush()
159+
assert(finished)
160+
assert(sub.exitCode() == 0)
161+
val expectedOutput = "output\n"
162+
val actualOutput = output.mkString("")
163+
assert(actualOutput == expectedOutput)
164+
sub.destroy()
166165
}
167166
}
167+
}
168168
}
169169
}

os/test/testSpawnExitHook/src/TestSpawnExitHook.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package test.os
22

3-
object TestSpawnExitHook{
3+
object TestSpawnExitHook {
44
def main(args: Array[String]): Unit = {
55
os.spawn((sys.env("TEST_SPAWN_EXIT_HOOK_ASSEMBLY2"), args(0)), shutdownHook = true)
66
Thread.sleep(99999)

0 commit comments

Comments
 (0)