import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertLinesMatch;

import java.nio.file.Path;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

class IntegrationTests {
  private static Bach bach(String... args) {
    var out = new Bach.Core.StringPrintWriter();
    var err = new Bach.Core.StringPrintWriter();
    return new Bach(Bach.Configuration.of(out, err, args));
  }

  @Test
  void buildDocTool(@TempDir Path temp) {
    var bach = bach("--verbose", "--chroot", "doc/tool", "--change-bach-out", temp.toString());
    var printer = bach.configuration().printer();
    var project = bach.configuration().project();
    var main = project.spaces().main();

    assertEquals("tool", project.name().value());
    assertEquals("123", project.version().value());
    assertEquals("2022-04-13T00:00Z", project.version().date().toString());
    assertEquals("org.example.app/org.example.app.Main", main.launcher().orElse("?"));

    bach.run("project/compile");
    assertLinesMatch(
        """
        project/compile
        Compile and package 3 main modules...
        >> JAVAC + JAR >>
        """
            .lines(),
        printer.out().toString().lines());

    var checkedLines = printer.out().toString().lines().count();

    bach.run("project/launch", "first", '2', 0x3);
    assertLinesMatch(
        """
        project/launch first 2 3
        Example application is running.
        file.+?/main/modules/org.example.app.jar
          module org.example.app
            package org.example.app
              class org.example.app.Main
         args -> (first 2 3)
        """
            .lines(),
        printer.out().toString().lines().skip(checkedLines));
  }
}

@@ -222,16 +222,121 @@
 TempDir;
+%0Aimport org.junit.jupiter.params.ParameterizedTest;%0Aimport org.junit.jupiter.params.provider.ValueSource;
 %0A%0Aclass 
@@ -1129,24 +1129,16 @@
 ch.run(%22
-project/
 compile%22
@@ -1182,24 +1182,16 @@
         
-project/
 compile%0A
@@ -1420,24 +1420,16 @@
 ch.run(%22
-project/
 launch%22,
@@ -1495,16 +1495,8 @@
     
-project/
 laun
@@ -1762,32 +1762,32 @@
       .lines(),%0A
-
         printer.
@@ -1835,11 +1835,315 @@
 s));%0A  %7D
+%0A%0A  @ParameterizedTest%0A  @ValueSource(strings = %7B%22aggregator%22, %22hello%22, %22hello-world%22, %22multi-release%22%7D)%0A  void buildExampleProject(String name, @TempDir Path temp) %7B%0A    var bach =%0A        bach(%22--chroot%22, %22doc/example-projects/%22 + name, %22--change-bach-out%22, temp.toString());%0A    bach.run(%22build%22);%0A  %7D
 %0A%7D%0A

Add integration test building each example project