Skip to content

Commit

Permalink
Test commands database generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrolamarao committed Oct 2, 2023
1 parent 47345bb commit 0e4bdc7
Showing 1 changed file with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
import org.gradle.testkit.runner.GradleRunner;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

import static org.junit.jupiter.api.Assertions.assertTrue;

public class CommandsFunctionalTest
{
@TempDir Path projectDir;
Expand All @@ -30,4 +34,60 @@ public void apply () throws IOException
.withArguments("commands")
.build();
}

@ParameterizedTest
@ValueSource(strings={"asm","c","cxx","ixx"})
public void language (String language) throws IOException
{
final var subprojectDir = projectDir.resolve("sub");
final var subprojectSourceDir = subprojectDir.resolve("src/main/%s".formatted(language));

Files.createDirectories(subprojectSourceDir);

Files.writeString(subprojectDir.resolve("build.gradle.kts"),
"""
plugins {
id("br.dev.pedrolamarao.metal.%s")
}
metal {
%s {
create("main")
}
}
""".formatted(language,language)
);

Files.writeString(subprojectSourceDir.resolve("foo.%s".formatted(language)),
"""
"""
);

Files.writeString(projectDir.resolve("build.gradle.kts"),
"""
plugins {
id("br.dev.pedrolamarao.metal.commands")
}
dependencies {
commands(project(":sub"))
}
""".formatted(language,language)
);

Files.writeString(projectDir.resolve("settings.gradle.kts"),
"""
include("sub")
"""
);

GradleRunner.create()
.withPluginClasspath()
.withProjectDir(projectDir.toFile())
.withDebug(true)
.withArguments("commands")
.build();

assertTrue( Files.exists( projectDir.resolve("compile_commands.json") ) );
}
}

0 comments on commit 0e4bdc7

Please sign in to comment.