@@ -17,7 +17,8 @@ class ConfigConverterTest extends AnyFlatSpec {
17
17
val dummyNativeConfigOptions = NativeConfigOptions ()
18
18
val dummyConfigOptions = ConfigOptions ()
19
19
20
- val dummyArguments = Seq (" $Main" , " A.nir" , " B.nir" ) // TODO incomplete arguments
20
+ val dummyArguments =
21
+ Seq (" $Main" , " A.nir" , " B.nir" )
21
22
22
23
val dummyCliOptions : CliOptions = CliOptions (
23
24
config = dummyConfigOptions,
@@ -30,28 +31,33 @@ class ConfigConverterTest extends AnyFlatSpec {
30
31
assert(config.isRight)
31
32
}
32
33
33
- // TODO incomplete arguments check reporting
34
-
35
- // it should "return default nativeConfig which lines up with empty nativeConfig" in {
36
- // val withInternallyDiscovered =
37
- // CliOptions(
38
- // dummyConfigOptions,
39
- // NativeConfigOptions(clang = Some(""), clangPP = Some("")),
40
- // logger = dummyLoggerOptions
41
- // )
42
- // val result = ConfigConverter.convert(withInternallyDiscovered, dummyArguments )
43
- // assert(result.right .get.config.compilerConfig == NativeConfig.empty )
44
- // }
34
+ // TODO incomplete arguments check reporting
35
+ it should " report incomplete arguments " in {
36
+ val noArgs = Seq ()
37
+ val noArgsResult = ConfigConverter .convert(dummyCliOptions, noArgs)
38
+ assert(noArgsResult.isLeft)
39
+ assert(noArgsResult.left.get. isInstanceOf [ IllegalArgumentException ])
40
+
41
+ val mainOnly = Seq ( " Main$ " )
42
+ val mainOnlyResult = ConfigConverter .convert(dummyCliOptions, mainOnly )
43
+ assert(mainOnlyResult.isLeft )
44
+ assert(mainOnlyResult.left .get.isInstanceOf [ IllegalArgumentException ] )
45
+ }
45
46
46
47
it should " parse classpath strings correctly" in {
47
- val classPathStrings = Seq (" /home/dir/file" , " /home/dirfile2" , " /home/dir/with spaces/" ) // check case app passing with spaces
48
+ val classPathStrings = Seq (
49
+ " /home/dir/file" ,
50
+ " /home/dirfile2" ,
51
+ " /home/dir/with spaces/"
52
+ ) // check case app passing with spaces
48
53
val expected = Seq (
49
54
Paths .get(" /home/dir/file" ),
50
55
Paths .get(" /home/dirfile2" ),
51
56
Paths .get(" /home/dir/with spaces/" )
52
57
)
53
58
54
- val config = ConfigConverter .convert(dummyCliOptions, Seq (" $Main" ) ++ classPathStrings)
59
+ val config =
60
+ ConfigConverter .convert(dummyCliOptions, Seq (" $Main" ) ++ classPathStrings)
55
61
56
62
assert(config != None )
57
63
assert(config.right.get.config.classPath.sameElements(expected))
@@ -61,10 +67,13 @@ class ConfigConverterTest extends AnyFlatSpec {
61
67
def gcAssertion (gcString : String , expectedGC : GC ) = {
62
68
val options = CliOptions (
63
69
dummyConfigOptions,
64
- NativeConfigOptions (gc = NativeConfigParserImplicits .gcParser(None , gcString).right.get),
70
+ NativeConfigOptions (gc =
71
+ NativeConfigParserImplicits .gcParser(None , gcString).right.get
72
+ ),
65
73
dummyLoggerOptions
66
74
)
67
- val config = ConfigConverter .convert(options, dummyArguments).right.get.config
75
+ val config =
76
+ ConfigConverter .convert(options, dummyArguments).right.get.config
68
77
assert(config.compilerConfig.gc == expectedGC)
69
78
}
70
79
gcAssertion(" immix" , GC .immix)
@@ -77,10 +86,13 @@ class ConfigConverterTest extends AnyFlatSpec {
77
86
def modeAssertion (modeString : String , expectedMode : Mode ) = {
78
87
val options = CliOptions (
79
88
dummyConfigOptions,
80
- NativeConfigOptions (mode = NativeConfigParserImplicits .modeParser(None , modeString).right.get),
89
+ NativeConfigOptions (mode =
90
+ NativeConfigParserImplicits .modeParser(None , modeString).right.get
91
+ ),
81
92
dummyLoggerOptions
82
93
)
83
- val config = ConfigConverter .convert(options, dummyArguments).right.get.config
94
+ val config =
95
+ ConfigConverter .convert(options, dummyArguments).right.get.config
84
96
assert(config.compilerConfig.mode == expectedMode)
85
97
}
86
98
modeAssertion(" debug" , Mode .debug)
@@ -92,10 +104,13 @@ class ConfigConverterTest extends AnyFlatSpec {
92
104
def ltoAssertion (ltoString : String , expectedLto : LTO ) = {
93
105
val options = CliOptions (
94
106
dummyConfigOptions,
95
- NativeConfigOptions (lto = NativeConfigParserImplicits .ltoParser(None , ltoString).right.get),
107
+ NativeConfigOptions (lto =
108
+ NativeConfigParserImplicits .ltoParser(None , ltoString).right.get
109
+ ),
96
110
dummyLoggerOptions
97
111
)
98
- val config = ConfigConverter .convert(options, dummyArguments).right.get.config
112
+ val config =
113
+ ConfigConverter .convert(options, dummyArguments).right.get.config
99
114
assert(config.compilerConfig.lto == expectedLto)
100
115
}
101
116
ltoAssertion(" none" , LTO .none)
@@ -160,12 +175,16 @@ class ConfigConverterTest extends AnyFlatSpec {
160
175
val expectedClangPPPath = Paths .get(clangPPString)
161
176
162
177
val options = CliOptions (
163
- dummyConfigOptions,
164
- NativeConfigOptions (clang= Some (clangString), clangPP = Some (clangPPString)),
178
+ dummyConfigOptions,
179
+ NativeConfigOptions (
180
+ clang = Some (clangString),
181
+ clangPP = Some (clangPPString)
182
+ ),
165
183
dummyLoggerOptions
166
184
)
167
185
168
- val nativeConfig = ConfigConverter .convert(options, dummyArguments).right.get
186
+ val nativeConfig =
187
+ ConfigConverter .convert(options, dummyArguments).right.get
169
188
170
189
assert(nativeConfig.config.compilerConfig.clang == expectedClangPath)
171
190
assert(nativeConfig.config.compilerConfig.clangPP == expectedClangPPPath)
0 commit comments