Skip to content

Commit

Permalink
Fix invalid subproject generated by added tests messing up other tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidOgunsAWS committed Sep 2, 2022
1 parent 71867e5 commit ae5ab86
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import software.amazon.smithy.rust.codegen.smithy.ServerCodegenContext
import software.amazon.smithy.rust.codegen.smithy.customize.CombinedCodegenDecorator
import software.amazon.smithy.rust.codegen.testutil.asSmithyModel
import software.amazon.smithy.rust.codegen.testutil.generatePluginContext
import java.nio.file.Files.createDirectory
import java.nio.file.Files.write
import java.nio.file.StandardOpenOption

class ServerCodegenVisitorTest {
@Test
Expand Down Expand Up @@ -43,7 +46,9 @@ class ServerCodegenVisitorTest {
greeting: String
}
""".asSmithyModel(smithyVersion = "2.0")
val (ctx, _) = generatePluginContext(model)
val (ctx, testDir) = generatePluginContext(model)
createDirectory(testDir.resolve("src"))
write(testDir.resolve("src/main.rs"), mutableListOf("fn main() {}"), StandardOpenOption.CREATE_NEW)
val codegenDecorator: CombinedCodegenDecorator<ServerCodegenContext> =
CombinedCodegenDecorator.fromClasspath(ctx, ServerRequiredCustomizations())
val visitor = ServerCodegenVisitor(ctx, codegenDecorator)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import software.amazon.smithy.rust.codegen.smithy.customize.RequiredCustomizatio
import software.amazon.smithy.rust.codegen.smithy.generators.client.FluentClientDecorator
import software.amazon.smithy.rust.codegen.testutil.asSmithyModel
import software.amazon.smithy.rust.codegen.testutil.generatePluginContext
import java.nio.file.Files.createDirectory
import java.nio.file.Files.write
import java.nio.file.StandardOpenOption

class CodegenVisitorTest {
@Test
Expand Down Expand Up @@ -45,7 +48,10 @@ class CodegenVisitorTest {
greeting: String
}
""".asSmithyModel(smithyVersion = "2.0")
val (ctx, _) = generatePluginContext(model)
val (ctx, testDir) = generatePluginContext(model)
createDirectory(testDir.resolve("src"))
write(testDir.resolve("src/main.rs"), mutableListOf("fn main() {}"), StandardOpenOption.CREATE_NEW)

val codegenDecorator =
CombinedCodegenDecorator.fromClasspath(
ctx,
Expand All @@ -54,7 +60,7 @@ class CodegenVisitorTest {
FluentClientDecorator(),
NoOpEventStreamSigningDecorator(),
)
val visitor = CodegenVisitor(ctx, codegenDecorator)
val visitor = CodegenVisitor(ctx, codegenDecorator).apply { execute() }
val baselineModel = visitor.baselineTransform(model)
baselineModel.getShapesWithTrait(ShapeId.from("smithy.api#mixin")).isEmpty() shouldBe true
}
Expand Down

0 comments on commit ae5ab86

Please sign in to comment.