forked from scala-js/scala-js-js-envs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRunConfigTest.scala
120 lines (108 loc) · 2.89 KB
/
RunConfigTest.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
* Scala.js JS Envs (https://github.com/scala-js/scala-js-js-envs)
*
* Copyright EPFL.
*
* Licensed under Apache License 2.0
* (https://www.apache.org/licenses/LICENSE-2.0).
*
* See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*/
package org.scalajs.jsenv
import org.junit.Test
import org.junit.Assert._
class RunConfigTest {
@Test
def supportedInheritIO: Unit = {
val cfg = RunConfig()
.withInheritOut(true)
.withInheritErr(true)
RunConfig.Validator()
.supportsInheritIO()
.validate(cfg)
}
@Test(expected = classOf[IllegalArgumentException])
def unsupportedInheritOut: Unit = {
val cfg = RunConfig()
.withInheritOut(true)
.withInheritErr(false)
.withOnOutputStream((_, _) => ())
RunConfig.Validator()
.supportsOnOutputStream()
.validate(cfg)
}
@Test(expected = classOf[IllegalArgumentException])
def unsupportedInheritErr: Unit = {
val cfg = RunConfig()
.withInheritOut(false)
.withInheritErr(true)
.withOnOutputStream((_, _) => ())
RunConfig.Validator()
.supportsOnOutputStream()
.validate(cfg)
}
@Test
def supportedOnOutputStream: Unit = {
val cfg = RunConfig()
.withInheritOut(false)
.withInheritErr(false)
.withOnOutputStream((_, _) => ())
RunConfig.Validator()
.supportsOnOutputStream()
.validate(cfg)
}
@Test(expected = classOf[IllegalArgumentException])
def unsupportedOnOutputStream: Unit = {
val cfg = RunConfig()
.withInheritOut(false)
.withInheritErr(false)
.withOnOutputStream((_, _) => ())
RunConfig.Validator()
.validate(cfg)
}
@Test(expected = classOf[IllegalArgumentException])
def missingOnOutputStreamNoInheritOut: Unit = {
val cfg = RunConfig()
.withInheritOut(false)
.withInheritErr(true)
RunConfig.Validator()
.supportsInheritIO()
.supportsOnOutputStream()
.validate(cfg)
}
@Test(expected = classOf[IllegalArgumentException])
def missingOnOutputStreamNoInheritErr: Unit = {
val cfg = RunConfig()
.withInheritOut(true)
.withInheritErr(false)
RunConfig.Validator()
.supportsInheritIO()
.supportsOnOutputStream()
.validate(cfg)
}
@Test
def supportedEnv: Unit = {
val cfg = RunConfig()
.withEnv(Map("x" -> "y"))
RunConfig.Validator()
.supportsInheritIO()
.supportsEnv()
.validate(cfg)
}
@Test(expected = classOf[IllegalArgumentException])
def unsupportedEnv: Unit = {
val cfg = RunConfig()
.withEnv(Map("x" -> "y"))
RunConfig.Validator()
.supportsInheritIO()
.validate(cfg)
}
@Test(expected = classOf[IllegalArgumentException])
def failValidationForTest: Unit = {
val cfg = RunConfig()
.withEternallyUnsupportedOption(true)
RunConfig.Validator()
.validate(cfg)
}
}