CQ. Work around updating reused elements text in MacroIncrementalTest.

Change-Id: Ic8cc02e38c24012ee738099962bbde374af26579
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378765
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/test/src/summary/macro_test.dart b/pkg/analyzer/test/src/summary/macro_test.dart
index c1b2c52..bc2c16f 100644
--- a/pkg/analyzer/test/src/summary/macro_test.dart
+++ b/pkg/analyzer/test/src/summary/macro_test.dart
@@ -12168,7 +12168,11 @@
 class X {}
 ''');
 
-    var expectedLibraryText = r'''
+    void assertElementText(LibraryElementImpl element) {
+      configuration
+        ..withConstructors = false
+        ..withMetadata = false;
+      checkElementText(element, r'''
 library
   reference: <testLibrary>
   libraryImports
@@ -12223,12 +12227,10 @@
               reference: <testLibrary>::@fragment::package:test/test.macro.dart::@classAugmentation::X::@method::foo
               enclosingElement: <testLibrary>::@fragment::package:test/test.macro.dart::@classAugmentation::X
               returnType: void
-''';
+''');
+    }
 
-    configuration
-      ..withConstructors = false
-      ..withMetadata = false;
-    checkElementText(library1, expectedLibraryText);
+    assertElementText(library1);
 
     // Generated and put into the cache.
     _assertMacroCachedGenerated(testFile, r'''
@@ -12245,7 +12247,7 @@
     await contextFor(testFile).applyPendingFileChanges();
 
     var library2 = await buildFileLibrary(testFile);
-    checkElementText(library2, expectedLibraryText);
+    assertElementText(library2);
 
     // Used cached, no new generated.
     _assertMacroCachedGenerated(testFile, r'''
@@ -12270,7 +12272,11 @@
 class X {}
 ''');
 
-    var expectedLibraryText = r'''
+    void assertElementText(LibraryElementImpl element) {
+      configuration
+        ..withConstructors = false
+        ..withMetadata = false;
+      checkElementText(element, r'''
 library
   reference: <testLibrary>
   libraryImports
@@ -12345,12 +12351,10 @@
               reference: <testLibrary>::@fragment::package:test/test.macro.dart::@classAugmentation::X::@method::foo
               enclosingElement: <testLibrary>::@fragment::package:test/test.macro.dart::@classAugmentation::X
               returnType: A
-''';
+''');
+    }
 
-    configuration
-      ..withConstructors = false
-      ..withMetadata = false;
-    checkElementText(library1, expectedLibraryText);
+    assertElementText(library1);
 
     // Generated and put into the cache.
     _assertMacroCachedGenerated(testFile, r'''
@@ -12368,7 +12372,7 @@
     await contextFor(testFile).applyPendingFileChanges();
 
     var library2 = await buildFileLibrary(testFile);
-    checkElementText(library2, expectedLibraryText);
+    assertElementText(library2);
 
     // Cannot prove that `package:test/test.dart@A` is still there.
     // So, not used cached.