@@ -1109,144 +1109,145 @@ class BspCompileSpec(
1109
1109
}
1110
1110
}
1111
1111
1112
- test(" support -Xfatal-warnings internal implementation" ) {
1113
- TestUtil .withinWorkspace { workspace =>
1114
- object Sources {
1115
- val `Foo.scala` =
1116
- """ /Foo.scala
1117
- |import Predef.assert
1118
- |class Foo
1112
+ for (fatalOpt <- List (" -Xfatal-warnings" , " -Werror" ))
1113
+ test(s " support $fatalOpt internal implementation " ) {
1114
+ TestUtil .withinWorkspace { workspace =>
1115
+ object Sources {
1116
+ val `Foo.scala` =
1117
+ """ /Foo.scala
1118
+ |import Predef.assert
1119
+ |class Foo
1119
1120
""" .stripMargin
1120
- val `Bar.scala` =
1121
- """ /Bar.scala
1122
- |class Bar
1121
+ val `Bar.scala` =
1122
+ """ /Bar.scala
1123
+ |class Bar
1123
1124
""" .stripMargin
1124
- val `Baz.scala` =
1125
- """ /Baz.scala
1126
- |class Baz
1125
+ val `Baz.scala` =
1126
+ """ /Baz.scala
1127
+ |class Baz
1127
1128
""" .stripMargin
1128
- val `Foo2.scala` =
1129
- """ /Foo.scala
1130
- |class Foo
1129
+ val `Foo2.scala` =
1130
+ """ /Foo.scala
1131
+ |class Foo
1131
1132
""" .stripMargin
1132
- val `Foo3.scala` =
1133
- """ /Foo.scala
1134
- |import Predef.assert
1135
- |import Predef.Manifest
1136
- |class Foo
1133
+ val `Foo3.scala` =
1134
+ """ /Foo.scala
1135
+ |import Predef.assert
1136
+ |import Predef.Manifest
1137
+ |class Foo
1137
1138
""" .stripMargin
1138
- val `Buzz.scala` =
1139
- """ /Buzz.scala
1140
- |class Buzz
1139
+ val `Buzz.scala` =
1140
+ """ /Buzz.scala
1141
+ |class Buzz
1141
1142
""" .stripMargin
1142
- val `Buzz2.scala` =
1143
- """ /Buzz.scala
1144
- |import Predef.assert
1145
- |class Buzz
1143
+ val `Buzz2.scala` =
1144
+ """ /Buzz.scala
1145
+ |import Predef.assert
1146
+ |class Buzz
1146
1147
""" .stripMargin
1147
- }
1148
+ }
1148
1149
1149
- val bspLogger = new RecordingLogger (ansiCodesSupported = false )
1150
- val sourcesA = List (Sources .`Bar.scala`, Sources .`Foo.scala`, Sources .`Baz.scala`)
1151
- val sourcesB = List (Sources .`Buzz.scala`)
1152
- val options = List (" -Ywarn-unused" , " -Xfatal-warnings " )
1153
- val `A` = TestProject (workspace, " a" , sourcesA, scalacOptions = options)
1154
- val `B` = TestProject (workspace, " b" , sourcesB, List (`A`), scalacOptions = options)
1155
- val projects = List (`A`, `B`)
1156
- loadBspState(workspace, projects, bspLogger) { state =>
1157
- val compiledState = state.compile(`B`)
1158
- assertExitStatus(compiledState, ExitStatus .CompilationError )
1159
- assertValidCompilationState(compiledState, projects)
1160
- assertNoDiff(
1161
- compiledState.lastDiagnostics(`A`),
1162
- """ |#1: task start 1
1163
- | -> Msg: Compiling a (3 Scala sources)
1164
- | -> Data kind: compile-task
1165
- |#1: a/src/Foo.scala
1166
- | -> List(Diagnostic(Range(Position(0,0),Position(0,7)),Some(Error),Some(_),Some(_),Unused import,None,None,Some({"actions":[]})))
1167
- | -> reset = true
1168
- |#1: task finish 1
1169
- | -> errors 1, warnings 0
1170
- | -> Msg: Compiled 'a'
1171
- | -> Data kind: compile-report
1172
- |""" .stripMargin
1173
- )
1150
+ val bspLogger = new RecordingLogger (ansiCodesSupported = false )
1151
+ val sourcesA = List (Sources .`Bar.scala`, Sources .`Foo.scala`, Sources .`Baz.scala`)
1152
+ val sourcesB = List (Sources .`Buzz.scala`)
1153
+ val options = List (" -Ywarn-unused" , fatalOpt )
1154
+ val `A` = TestProject (workspace, " a" , sourcesA, scalacOptions = options)
1155
+ val `B` = TestProject (workspace, " b" , sourcesB, List (`A`), scalacOptions = options)
1156
+ val projects = List (`A`, `B`)
1157
+ loadBspState(workspace, projects, bspLogger) { state =>
1158
+ val compiledState = state.compile(`B`)
1159
+ assertExitStatus(compiledState, ExitStatus .CompilationError )
1160
+ assertValidCompilationState(compiledState, projects)
1161
+ assertNoDiff(
1162
+ compiledState.lastDiagnostics(`A`),
1163
+ """ |#1: task start 1
1164
+ | -> Msg: Compiling a (3 Scala sources)
1165
+ | -> Data kind: compile-task
1166
+ |#1: a/src/Foo.scala
1167
+ | -> List(Diagnostic(Range(Position(0,0),Position(0,7)),Some(Error),Some(_),Some(_),Unused import,None,None,Some({"actions":[]})))
1168
+ | -> reset = true
1169
+ |#1: task finish 1
1170
+ | -> errors 1, warnings 0
1171
+ | -> Msg: Compiled 'a'
1172
+ | -> Data kind: compile-report
1173
+ |""" .stripMargin
1174
+ )
1174
1175
1175
- assertNoDiff(
1176
- compiledState.lastDiagnostics(`B`),
1177
- """ |#1: task start 2
1178
- | -> Msg: Compiling b (1 Scala source)
1179
- | -> Data kind: compile-task
1180
- |#1: task finish 2
1181
- | -> errors 0, warnings 0
1182
- | -> Msg: Compiled 'b'
1183
- | -> Data kind: compile-report
1184
- |""" .stripMargin
1185
- )
1176
+ assertNoDiff(
1177
+ compiledState.lastDiagnostics(`B`),
1178
+ """ |#1: task start 2
1179
+ | -> Msg: Compiling b (1 Scala source)
1180
+ | -> Data kind: compile-task
1181
+ |#1: task finish 2
1182
+ | -> errors 0, warnings 0
1183
+ | -> Msg: Compiled 'b'
1184
+ | -> Data kind: compile-report
1185
+ |""" .stripMargin
1186
+ )
1186
1187
1187
- writeFile(`A`.srcFor(" /Foo.scala" ), Sources .`Foo2.scala`)
1188
- val secondCompiledState = compiledState.compile(`B`)
1189
- assertExitStatus(secondCompiledState, ExitStatus .Ok )
1190
- assertValidCompilationState(secondCompiledState, projects)
1191
- assertNoDiff(
1192
- secondCompiledState.lastDiagnostics(`A`),
1193
- """ |#2: task start 3
1194
- | -> Msg: Compiling a (1 Scala source)
1195
- | -> Data kind: compile-task
1196
- |#2: a/src/Foo.scala
1197
- | -> List()
1198
- | -> reset = true
1199
- |#2: task finish 3
1200
- | -> errors 0, warnings 0
1201
- | -> Msg: Compiled 'a'
1202
- | -> Data kind: compile-report
1203
- |""" .stripMargin
1204
- )
1188
+ writeFile(`A`.srcFor(" /Foo.scala" ), Sources .`Foo2.scala`)
1189
+ val secondCompiledState = compiledState.compile(`B`)
1190
+ assertExitStatus(secondCompiledState, ExitStatus .Ok )
1191
+ assertValidCompilationState(secondCompiledState, projects)
1192
+ assertNoDiff(
1193
+ secondCompiledState.lastDiagnostics(`A`),
1194
+ """ |#2: task start 3
1195
+ | -> Msg: Compiling a (1 Scala source)
1196
+ | -> Data kind: compile-task
1197
+ |#2: a/src/Foo.scala
1198
+ | -> List()
1199
+ | -> reset = true
1200
+ |#2: task finish 3
1201
+ | -> errors 0, warnings 0
1202
+ | -> Msg: Compiled 'a'
1203
+ | -> Data kind: compile-report
1204
+ |""" .stripMargin
1205
+ )
1205
1206
1206
- assertNoDiff(
1207
- compiledState.lastDiagnostics(`B`),
1208
- " " // no-op
1209
- )
1207
+ assertNoDiff(
1208
+ compiledState.lastDiagnostics(`B`),
1209
+ " " // no-op
1210
+ )
1210
1211
1211
- writeFile(`A`.srcFor(" /Foo.scala" ), Sources .`Foo3.scala`)
1212
- writeFile(`B`.srcFor(" /Buzz.scala" ), Sources .`Buzz2.scala`)
1213
- val thirdCompiledState = secondCompiledState.compile(`B`)
1214
- assertExitStatus(thirdCompiledState, ExitStatus .CompilationError )
1215
- assertValidCompilationState(thirdCompiledState, projects)
1216
- assertNoDiff(
1217
- thirdCompiledState.lastDiagnostics(`A`),
1218
- """ |#3: task start 4
1219
- | -> Msg: Compiling a (1 Scala source)
1220
- | -> Data kind: compile-task
1221
- |#3: a/src/Foo.scala
1222
- | -> List(Diagnostic(Range(Position(0,0),Position(0,7)),Some(Error),Some(_),Some(_),Unused import,None,None,Some({"actions":[]})))
1223
- | -> reset = true
1224
- |#3: a/src/Foo.scala
1225
- | -> List(Diagnostic(Range(Position(1,0),Position(1,7)),Some(Error),Some(_),Some(_),Unused import,None,None,Some({"actions":[]})))
1226
- | -> reset = false
1227
- |#3: task finish 4
1228
- | -> errors 2, warnings 0
1229
- | -> Msg: Compiled 'a'
1230
- | -> Data kind: compile-report
1231
- |""" .stripMargin
1232
- )
1212
+ writeFile(`A`.srcFor(" /Foo.scala" ), Sources .`Foo3.scala`)
1213
+ writeFile(`B`.srcFor(" /Buzz.scala" ), Sources .`Buzz2.scala`)
1214
+ val thirdCompiledState = secondCompiledState.compile(`B`)
1215
+ assertExitStatus(thirdCompiledState, ExitStatus .CompilationError )
1216
+ assertValidCompilationState(thirdCompiledState, projects)
1217
+ assertNoDiff(
1218
+ thirdCompiledState.lastDiagnostics(`A`),
1219
+ """ |#3: task start 4
1220
+ | -> Msg: Compiling a (1 Scala source)
1221
+ | -> Data kind: compile-task
1222
+ |#3: a/src/Foo.scala
1223
+ | -> List(Diagnostic(Range(Position(0,0),Position(0,7)),Some(Error),Some(_),Some(_),Unused import,None,None,Some({"actions":[]})))
1224
+ | -> reset = true
1225
+ |#3: a/src/Foo.scala
1226
+ | -> List(Diagnostic(Range(Position(1,0),Position(1,7)),Some(Error),Some(_),Some(_),Unused import,None,None,Some({"actions":[]})))
1227
+ | -> reset = false
1228
+ |#3: task finish 4
1229
+ | -> errors 2, warnings 0
1230
+ | -> Msg: Compiled 'a'
1231
+ | -> Data kind: compile-report
1232
+ |""" .stripMargin
1233
+ )
1233
1234
1234
- assertNoDiff(
1235
- compiledState.lastDiagnostics(`B`),
1236
- """ |#3: task start 5
1237
- | -> Msg: Compiling b (1 Scala source)
1238
- | -> Data kind: compile-task
1239
- |#3: b/src/Buzz.scala
1240
- | -> List(Diagnostic(Range(Position(0,0),Position(0,7)),Some(Error),Some(_),Some(_),Unused import,None,None,Some({"actions":[]})))
1241
- | -> reset = true
1242
- |#3: task finish 5
1243
- | -> errors 1, warnings 0
1244
- | -> Msg: Compiled 'b'
1245
- | -> Data kind: compile-report
1246
- |""" .stripMargin
1247
- )
1235
+ assertNoDiff(
1236
+ compiledState.lastDiagnostics(`B`),
1237
+ """ |#3: task start 5
1238
+ | -> Msg: Compiling b (1 Scala source)
1239
+ | -> Data kind: compile-task
1240
+ |#3: b/src/Buzz.scala
1241
+ | -> List(Diagnostic(Range(Position(0,0),Position(0,7)),Some(Error),Some(_),Some(_),Unused import,None,None,Some({"actions":[]})))
1242
+ | -> reset = true
1243
+ |#3: task finish 5
1244
+ | -> errors 1, warnings 0
1245
+ | -> Msg: Compiled 'b'
1246
+ | -> Data kind: compile-report
1247
+ |""" .stripMargin
1248
+ )
1249
+ }
1248
1250
}
1249
1251
}
1250
- }
1251
1252
1252
1253
}
0 commit comments