Skip to content

Commit f925e94

Browse files
authored
PR to update the golden samples test to only run on migrated samples (#44471)
1 parent b540583 commit f925e94

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

sdk/tools/azure-openrewrite/pom.xml

-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@
223223
<suppressionsLocation>${project.basedir}/../../../eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
224224
<headerLocation>${project.basedir}/../../../eng/code-quality-reports/src/main/resources/checkstyle/java.header</headerLocation>
225225
<propertyExpansion>samedir=</propertyExpansion>
226-
<encoding>UTF-8</encoding>
227226
<consoleOutput>true</consoleOutput>
228227
<includeTestSourceDirectory>true</includeTestSourceDirectory>
229228
<linkXRef>true</linkXRef>

sdk/tools/azure-openrewrite/src/test/java/com/azure/openrewrite/migration/FullSampleMigrationTest.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class FullSampleMigrationTest implements RewriteTest {
2828

2929
static final String GOLDEN_IMAGE = "v2";
3030
static final String ORIGINAL_IMAGE = "v1";
31-
31+
static final String RECIPE_NAME = "com.azure.openrewrite.migrateToVNext";
3232
static final String[] DISABLED_DIRS = {
3333
"src/test/resources/migrationExamples/azure-storage-blob/"
3434
};
@@ -67,13 +67,13 @@ static Stream<Path> gatherAllRegularFiles(Path sampleDir) throws IOException {
6767

6868
@Override
6969
public void defaults(RecipeSpec spec) {
70-
spec.recipeFromResources("com.azure.openrewrite.migrateToVNext")
70+
System.out.printf("Active recipe: %s\n", RECIPE_NAME);
71+
spec.recipeFromResources(RECIPE_NAME)
7172
.typeValidationOptions(TypeValidation.none());
7273
}
7374

7475

7576

76-
7777
@ParameterizedTest
7878
@MethodSource("sampleDirectories")
7979
public void testGoldenImage(Path sampleDir) throws Exception {
@@ -98,14 +98,20 @@ public void testGoldenImage(Path sampleDir) throws Exception {
9898
public void assertFullMigration(Map<String,String> fileMap) throws IOException {
9999
List<SourceSpecs> sourceSpecs = new ArrayList<SourceSpecs>();
100100
for (Map.Entry<String,String> entry : fileMap.entrySet()) {
101+
101102
String before = Files.readAllLines(Paths.get(entry.getKey()))
102103
.stream()
103104
.reduce("", (a, b) -> a + b + "\n");
104105

105106
String after = Files.readAllLines(Paths.get(entry.getValue()))
106107
.stream()
107108
.reduce("", (a, b) -> a + b + "\n");
108-
sourceSpecs.add(java(before, after));
109+
if (!before.equals(after)) {
110+
sourceSpecs.add(java(before, after));
111+
}
112+
}
113+
if (sourceSpecs.isEmpty()) {
114+
Assumptions.abort("Migration samples are identical. No migration detected.");
109115
}
110116
rewriteRun(
111117
sourceSpecs.toArray(new SourceSpecs[sourceSpecs.size()])

0 commit comments

Comments
 (0)