Search in sources :

Example 6 with BuckBuildCommandHandler

use of com.facebook.buck.intellij.ideabuck.build.BuckBuildCommandHandler in project buck by facebook.

the class TestExecutionState method runBuildCommand.

private ProcessHandler runBuildCommand(Executor executor) {
    final BuckModule buckModule = mProject.getComponent(BuckModule.class);
    final String target = mConfiguration.data.target;
    final String additionalParams = mConfiguration.data.additionalParams;
    final String testSelectors = mConfiguration.data.testSelectors;
    final String title = "Buck Test " + target;
    buckModule.attach(target);
    final BuckBuildCommandHandler handler = new BuckBuildCommandHandler(mProject, mProject.getBaseDir(), BuckCommand.TEST, /* doStartNotify */
    false) {

        @Override
        protected void notifyLines(Key outputType, Iterable<String> lines) {
            super.notifyLines(outputType, lines);
            if (outputType != ProcessOutputTypes.STDERR) {
                return;
            }
            for (String line : lines) {
                final Matcher matcher = DEBUG_SUSPEND_PATTERN.matcher(line);
                if (matcher.find()) {
                    final String port = matcher.group(1);
                    attachDebugger(title, port);
                }
            }
        }
    };
    if (!target.isEmpty()) {
        handler.command().addParameter(target);
    }
    if (!testSelectors.isEmpty()) {
        handler.command().addParameter("--test-selectors");
        handler.command().addParameter(testSelectors);
    }
    if (!additionalParams.isEmpty()) {
        for (String param : additionalParams.split("\\s")) {
            handler.command().addParameter(param);
        }
    }
    if (executor.getId().equals(DefaultDebugExecutor.EXECUTOR_ID)) {
        handler.command().addParameter("--debug");
    }
    handler.start();
    final OSProcessHandler result = handler.getHandler();
    showProgress(result, title);
    return result;
}
Also used : BuckModule(com.facebook.buck.intellij.ideabuck.config.BuckModule) Matcher(java.util.regex.Matcher) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) BuckBuildCommandHandler(com.facebook.buck.intellij.ideabuck.build.BuckBuildCommandHandler) Key(com.intellij.openapi.util.Key)

Aggregations

BuckBuildCommandHandler (com.facebook.buck.intellij.ideabuck.build.BuckBuildCommandHandler)6 BuckModule (com.facebook.buck.intellij.ideabuck.config.BuckModule)6 BuckBuildManager (com.facebook.buck.intellij.ideabuck.build.BuckBuildManager)5 Project (com.intellij.openapi.project.Project)5 Matcher (java.util.regex.Matcher)2 BuckSettingsProvider (com.facebook.buck.intellij.ideabuck.config.BuckSettingsProvider)1 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)1 Key (com.intellij.openapi.util.Key)1