@@ -42,6 +42,19 @@ import java.nio.file.Files.createTempDirectory
4242import java.nio.file.Path
4343import kotlin.io.path.absolutePathString
4444
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+
4558val TestModuleDocProvider = object : ModuleDocProvider {
4659 override fun docsWriter (module : RustModule .LeafModule ): Writable = writable {
4760 docs(" Some test documentation\n\n Some more details..." )
@@ -332,14 +345,14 @@ fun TestWriterDelegator.compileAndTest(
332345 println (" Generated files:" )
333346 printGeneratedFiles()
334347 try {
335- " cargo fmt " .runCommand(baseDir)
348+ Commands . CargoFmt .runCommand(baseDir)
336349 } catch (e: Exception ) {
337350 // cargo fmt errors are useless, ignore
338351 }
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)
341354 if (runClippy) {
342- " cargo clippy " .runCommand(baseDir, env)
355+ Commands . CargoClippy .runCommand(baseDir, env)
343356 }
344357 return testOutput
345358}
@@ -379,9 +392,9 @@ fun RustWriter.compileAndTest(
379392 val testModule = tempDir.resolve(" src/$module .rs" )
380393 try {
381394 val testOutput = if ((mainRs.readText() + testModule.readText()).contains(" #[test]" )) {
382- " cargo test " .runCommand(tempDir.toPath())
395+ Commands . CargoTest .runCommand(tempDir.toPath())
383396 } else {
384- " cargo check " .runCommand(tempDir.toPath())
397+ Commands . CargoCheck .runCommand(tempDir.toPath())
385398 }
386399 if (expectFailure) {
387400 println (" Test sources for debugging: file://${testModule.absolutePath} " )
@@ -488,4 +501,4 @@ fun TestWriterDelegator.unitTest(test: Writable): TestWriterDelegator {
488501 return this
489502}
490503
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