@@ -42,6 +42,19 @@ import java.nio.file.Files.createTempDirectory
42
42
import java.nio.file.Path
43
43
import kotlin.io.path.absolutePathString
44
44
45
+ object Commands {
46
+ val CargoEnvDWarnings = mapOf (
47
+ " RUSTFLAGS" to " -D warnings --cfg aws_sdk_unstable" ,
48
+ )
49
+ val CargoEnvDDeadCode = mapOf (
50
+ " RUSTFLAGS" to " -A dead_code --cfg aws_sdk_unstable" ,
51
+ )
52
+ const val CargoTest = " cargo test --all-features"
53
+ const val CargoCheck = " cargo check --all-features"
54
+ const val CargoFmt = " cargo fmt "
55
+ const val CargoClippy = " cargo clippy"
56
+ }
57
+
45
58
val TestModuleDocProvider = object : ModuleDocProvider {
46
59
override fun docsWriter (module : RustModule .LeafModule ): Writable = writable {
47
60
docs(" Some test documentation\n\n Some more details..." )
@@ -332,14 +345,14 @@ fun TestWriterDelegator.compileAndTest(
332
345
println (" Generated files:" )
333
346
printGeneratedFiles()
334
347
try {
335
- " cargo fmt " .runCommand(baseDir)
348
+ Commands . CargoFmt .runCommand(baseDir)
336
349
} catch (e: Exception ) {
337
350
// cargo fmt errors are useless, ignore
338
351
}
339
- val env = mapOf ( " RUSTFLAGS " to " -A dead_code " )
340
- val testOutput = " cargo test " .runCommand(baseDir, env)
352
+ val env = Commands . CargoEnvDDeadCode
353
+ val testOutput = Commands . CargoTest .runCommand(baseDir, env)
341
354
if (runClippy) {
342
- " cargo clippy " .runCommand(baseDir, env)
355
+ Commands . CargoClippy .runCommand(baseDir, env)
343
356
}
344
357
return testOutput
345
358
}
@@ -379,9 +392,9 @@ fun RustWriter.compileAndTest(
379
392
val testModule = tempDir.resolve(" src/$module .rs" )
380
393
try {
381
394
val testOutput = if ((mainRs.readText() + testModule.readText()).contains(" #[test]" )) {
382
- " cargo test " .runCommand(tempDir.toPath())
395
+ Commands . CargoTest .runCommand(tempDir.toPath())
383
396
} else {
384
- " cargo check " .runCommand(tempDir.toPath())
397
+ Commands . CargoCheck .runCommand(tempDir.toPath())
385
398
}
386
399
if (expectFailure) {
387
400
println (" Test sources for debugging: file://${testModule.absolutePath} " )
@@ -488,4 +501,4 @@ fun TestWriterDelegator.unitTest(test: Writable): TestWriterDelegator {
488
501
return this
489
502
}
490
503
491
- fun String.runWithWarnings (crate : Path ) = this .runCommand(crate, mapOf ( " RUSTFLAGS " to " -D warnings " ) )
504
+ fun String.runWithWarnings (crate : Path ) = this .runCommand(crate, Commands . CargoEnvDWarnings )
0 commit comments