WEB-23055 Support ASCII control characters to improve webpack progress showing in...
[idea/community.git] / platform / platform-tests / testSrc / com / intellij / execution / process / AnsiEscapeDecoderTest.java
index 519837cf7aba72dcb5fbeef4d76a3fc5a97a2ebf..7853654c745859437bf52a8b861c5483462230b6 100644 (file)
@@ -3,7 +3,6 @@ package com.intellij.execution.process;
 import com.intellij.openapi.util.Key;
 import com.intellij.openapi.util.Pair;
 import com.intellij.testFramework.PlatformTestCase;
-import com.intellij.util.Function;
 import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.NotNull;
 import org.junit.Assert;
@@ -55,6 +54,22 @@ public class AnsiEscapeDecoderTest extends PlatformTestCase {
     );
   }
 
+  public void testBackspaceControlSequence() throws Exception {
+    AnsiEscapeDecoder decoder = new AnsiEscapeDecoder();
+    decoder.escapeText(" 10% 0/1 build modules\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b 70% 1/1 build modules",
+                       ProcessOutputTypes.STDERR,
+                       createExpectedAcceptor(
+                         Pair.create(" 70% 1/1 build modules", ProcessOutputTypes.STDERR)
+                       )
+    );
+    decoder.escapeText("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b 40% 1/2 build modules\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b 30% 1/3 build modules\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b 25% 1/4 build modules",
+                       ProcessOutputTypes.STDERR,
+                       createExpectedAcceptor(
+                         Pair.create("\n 25% 1/4 build modules", ProcessOutputTypes.STDERR)
+                       )
+    );
+  }
+
   @NotNull
   private static List<Pair<String, String>> toListWithKeyName(@NotNull Collection<Pair<String, Key>> list) {
     return ContainerUtil.map(list, pair -> Pair.create(pair.first, pair.second.toString()));