package test.integration;

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

import com.github.sormuras.bach.Bach;
import com.github.sormuras.bach.Main;
import com.github.sormuras.bach.Printer;
import com.github.sormuras.bach.ToolCall;
import com.github.sormuras.bach.project.DeclaredModule;
import com.github.sormuras.bach.project.ExternalTool;
import java.util.Set;
import java.util.stream.Stream;
import org.junit.jupiter.api.Test;

class MainTests {
  @Test
  void modules() {
    var project = bach().project();
    assertLinesMatch(
        """
        com.github.sormuras.bach
        com.github.sormuras.bach
        test.base
        test.integration
        """
            .lines(),
        project.modules().stream().map(DeclaredModule::name).sorted());
    assertEquals(
        Set.of("com.github.sormuras.hello", "org.junit.platform.console"),
        project.externals().requires());
    assertLinesMatch(
        """
        format@.+""".lines(),
        project.externals().tools().stream().map(ExternalTool::name).sorted());
  }

  static Bach bach(String... args) {
    return bach(ToolCall.of("bach").with(Stream.of(args)));
  }

  static Bach bach(ToolCall call) {
    return Main.bach(Printer.ofSilence(), call.arguments().toArray(String[]::new));
  }
}

@@ -1111,32 +1111,258 @@
 sorted());%0A  %7D%0A%0A
+  @Test%0A  void info() %7B%0A    var bach = bach();%0A    bach.run(%22info%22);%0A    assertLinesMatch(%0A        %22%22%22%0A        info%0A        %3E%3E ... %3E%3E%0A        %22%22%22.lines(),%0A        bach.configuration().printer().out().toString().lines());%0A  %7D%0A%0A
   static Bach ba

Add test for `info` tool