Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring and adding aws_sdk_unstable to RUSTFLAG on one of the kotlin test #2804

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
8565bf2
test
thomas-k-cameron Jun 22, 2023
f578b86
Update codegen-core/src/main/kotlin/software/amazon/smithy/rust/codeg…
thomas-k-cameron Jun 22, 2023
268b876
Merge branch 'main' into RFC30/test2
thomas-k-cameron Jun 27, 2023
d614f5f
Rust.kt
thomas-k-cameron Jun 29, 2023
31c16bd
Merge branch 'RFC30/test2' of https://github.com/thomas-k-cameron/smi…
thomas-k-cameron Jun 29, 2023
0df1dfb
Merge branch 'main' into RFC30/test2
thomas-k-cameron Jun 29, 2023
e6512fb
asdf
thomas-k-cameron Jun 29, 2023
3624b37
pre-commit
thomas-k-cameron Jun 29, 2023
e0311c3
check
thomas-k-cameron Jun 29, 2023
6e87b13
Update codegen-core/src/main/kotlin/software/amazon/smithy/rust/codeg…
thomas-k-cameron Jun 29, 2023
2f25042
Update codegen-core/src/main/kotlin/software/amazon/smithy/rust/codeg…
thomas-k-cameron Jun 29, 2023
7e06e0c
FIX
thomas-k-cameron Jun 29, 2023
1acf514
Merge branch 'main' into RFC30/test2
thomas-k-cameron Jun 29, 2023
84c943d
fix
thomas-k-cameron Jun 29, 2023
c358294
fix
thomas-k-cameron Jun 29, 2023
99113b5
enable by default
thomas-k-cameron Jun 29, 2023
1e4ec95
Merge branch 'main' into RFC30/test2
thomas-k-cameron Jun 29, 2023
5a36064
fix
thomas-k-cameron Jun 29, 2023
2b24f9d
Merge branch 'RFC30/test2' of https://github.com/thomas-k-cameron/smi…
thomas-k-cameron Jun 29, 2023
970d4c2
Update Rust.kt
thomas-k-cameron Jul 4, 2023
cc33514
Update Rust.kt
thomas-k-cameron Jul 4, 2023
8d78bd4
fix
thomas-k-cameron Jul 6, 2023
7d80faf
better docs
thomas-k-cameron Jul 6, 2023
5756a41
update
thomas-k-cameron Jul 6, 2023
01a69fc
Merge branch 'main' into RFC30/test2
thomas-k-cameron Jul 6, 2023
0dca49e
Merge branches 'RFC30/test2' and 'RFC30/test2' of https://github.com/…
thomas-k-cameron Jul 6, 2023
1496901
fix
thomas-k-cameron Jul 6, 2023
73b40a4
fix
thomas-k-cameron Jul 6, 2023
2647de9
update
thomas-k-cameron Jul 6, 2023
16b51e3
Merge branch 'main' into RFC30/test2
thomas-k-cameron Jul 10, 2023
e7d4597
Merge branch 'main' into RFC30/test2
thomas-k-cameron Aug 17, 2023
5b7d9d1
Merge branch 'main' into RFC30/test2
thomas-k-cameron Aug 19, 2023
71d54cb
Merge branch 'main' into RFC30/test2
thomas-k-cameron Dec 9, 2023
d53c7c4
update
thomas-k-cameron Dec 9, 2023
c46ae34
modified: codegen-core/src/main/kotlin/software/amazon/smithy/rust/…
thomas-k-cameron Dec 9, 2023
ac6928d
update
thomas-k-cameron Dec 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ import java.nio.file.Files.createTempDirectory
import java.nio.file.Path
import kotlin.io.path.absolutePathString

object Commands {
thomas-k-cameron marked this conversation as resolved.
Show resolved Hide resolved
val CargoEnvDWarnings = mapOf(
"RUSTFLAGS" to "-D warnings --cfg aws_sdk_unstable",
)
val CargoEnvDDeadCode = mapOf(
"RUSTFLAGS" to "-A dead_code --cfg aws_sdk_unstable",
)
thomas-k-cameron marked this conversation as resolved.
Show resolved Hide resolved
const val CargoTest = "cargo test --all-features"
const val CargoCheck = "cargo check --all-features"
const val CargoFmt = "cargo fmt "
thomas-k-cameron marked this conversation as resolved.
Show resolved Hide resolved
const val CargoClippy = "cargo clippy"
}

val TestModuleDocProvider = object : ModuleDocProvider {
override fun docsWriter(module: RustModule.LeafModule): Writable = writable {
docs("Some test documentation\n\nSome more details...")
Expand Down Expand Up @@ -332,14 +345,14 @@ fun TestWriterDelegator.compileAndTest(
println("Generated files:")
printGeneratedFiles()
try {
"cargo fmt".runCommand(baseDir)
Commands.CargoFmt.runCommand(baseDir)
} catch (e: Exception) {
// cargo fmt errors are useless, ignore
}
val env = mapOf("RUSTFLAGS" to "-A dead_code")
val testOutput = "cargo test".runCommand(baseDir, env)
val env = Commands.CargoEnvDDeadCode
val testOutput = Commands.CargoTest.runCommand(baseDir, env)
if (runClippy) {
"cargo clippy".runCommand(baseDir, env)
Commands.CargoClippy.runCommand(baseDir, env)
}
return testOutput
}
Expand Down Expand Up @@ -379,9 +392,9 @@ fun RustWriter.compileAndTest(
val testModule = tempDir.resolve("src/$module.rs")
try {
val testOutput = if ((mainRs.readText() + testModule.readText()).contains("#[test]")) {
"cargo test".runCommand(tempDir.toPath())
Commands.CargoTest.runCommand(tempDir.toPath())
} else {
"cargo check".runCommand(tempDir.toPath())
Commands.CargoCheck.runCommand(tempDir.toPath())
}
if (expectFailure) {
println("Test sources for debugging: file://${testModule.absolutePath}")
Expand Down Expand Up @@ -488,4 +501,4 @@ fun TestWriterDelegator.unitTest(test: Writable): TestWriterDelegator {
return this
}

fun String.runWithWarnings(crate: Path) = this.runCommand(crate, mapOf("RUSTFLAGS" to "-D warnings"))
fun String.runWithWarnings(crate: Path) = this.runCommand(crate, Commands.CargoEnvDWarnings)