{"action":"created","comment":{"url":"https://api.github.com/repos/facebook/buck/pulls/comments/49932406","id":49932406,"diff_hunk":"@@ -0,0 +1,193 @@\n+/*\n+ * Copyright 2016-present Facebook, Inc.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n+ * not use this file except in compliance with the License. You may obtain\n+ * a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+ * License for the specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package com.facebook.buck.jvm.groovy;\n+\n+import com.facebook.buck.jvm.common.ResourceValidator;\n+import com.facebook.buck.jvm.java.CalculateAbi;\n+import com.facebook.buck.jvm.java.JavaLibrary;\n+import com.facebook.buck.jvm.java.JavaTest;\n+import com.facebook.buck.jvm.java.JavacOptions;\n+import com.facebook.buck.jvm.java.JavacOptionsFactory;\n+import com.facebook.buck.jvm.java.TestType;\n+import com.facebook.buck.model.BuildTarget;\n+import com.facebook.buck.parser.NoSuchBuildTargetException;\n+import com.facebook.buck.rules.BuildRule;\n+import com.facebook.buck.rules.BuildRuleParams;\n+import com.facebook.buck.rules.BuildRuleResolver;\n+import com.facebook.buck.rules.BuildRuleType;\n+import com.facebook.buck.rules.BuildRules;\n+import com.facebook.buck.rules.BuildTargetSourcePath;\n+import com.facebook.buck.rules.Description;\n+import com.facebook.buck.rules.Hint;\n+import com.facebook.buck.rules.Label;\n+import com.facebook.buck.rules.SourcePath;\n+import com.facebook.buck.rules.SourcePathResolver;\n+import com.facebook.buck.rules.TargetGraph;\n+import com.facebook.buck.util.HumanReadableException;\n+import com.facebook.infer.annotation.SuppressFieldNotInitialized;\n+import com.google.common.base.Optional;\n+import com.google.common.collect.ImmutableList;\n+import com.google.common.collect.ImmutableMap;\n+import com.google.common.collect.ImmutableSet;\n+import com.google.common.collect.ImmutableSortedSet;\n+import com.google.common.collect.Iterables;\n+\n+import java.nio.file.Path;\n+import java.util.logging.Level;\n+\n+public class GroovyTestDescription implements Description<GroovyTestDescription.Arg> {\n+\n+  public static final BuildRuleType TYPE = BuildRuleType.of(\"groovy_test\");\n+\n+  private final GroovyBuckConfig groovyBuckConfig;\n+  private final JavacOptions defaultJavacOptions;\n+  private final Optional<Long> defaultTestRuleTimeoutMs;\n+  private final Optional<Path> testTempDirOverride;\n+\n+  public GroovyTestDescription(\n+      GroovyBuckConfig groovyBuckConfig,\n+      JavacOptions defaultOptions,\n+      Optional<Long> defaultTestRuleTimeoutMs,\n+      Optional<Path> testTempDirOverride) {\n+    this.groovyBuckConfig = groovyBuckConfig;\n+    this.defaultJavacOptions = defaultOptions;\n+    this.defaultTestRuleTimeoutMs = defaultTestRuleTimeoutMs;\n+    this.testTempDirOverride = testTempDirOverride;\n+  }\n+\n+  @Override\n+  public BuildRuleType getBuildRuleType() {\n+    return TYPE;\n+  }\n+\n+  @Override\n+  public Arg createUnpopulatedConstructorArg() {\n+    return new Arg();\n+  }\n+\n+  @Override\n+  public <A extends Arg> JavaTest createBuildRule(\n+      TargetGraph targetGraph,\n+      BuildRuleParams params,\n+      BuildRuleResolver resolver,\n+      A args) throws NoSuchBuildTargetException {\n+    SourcePathResolver pathResolver = new SourcePathResolver(resolver);\n+\n+    BuildTarget abiJarTarget =\n+        BuildTarget.builder(params.getBuildTarget())\n+            .addFlavors(CalculateAbi.FLAVOR)\n+            .build();\n+\n+    GroovycToJarStepFactory stepFactory = new GroovycToJarStepFactory(\n+        groovyBuckConfig.getGroovyCompiler().get(),\n+        args.extraGroovycArguments,\n+        JavacOptionsFactory.create(\n+            defaultJavacOptions,\n+            params,\n+            resolver,\n+            pathResolver,\n+            args\n+        ));\n+\n+    JavaTest test =\n+        resolver.addToIndex(\n+            new JavaTest(\n+                params.appendExtraDeps(\n+                    Iterables.concat(\n+                        BuildRules.getExportedRules(\n+                            Iterables.concat(\n+                                params.getDeclaredDeps().get(),\n+                                resolver.getAllRules(args.providedDeps.get()))),\n+                        pathResolver.filterBuildRuleInputs(\n+                            defaultJavacOptions.getInputs(pathResolver)))),\n+                pathResolver,\n+                args.srcs.get(),\n+                ResourceValidator.validateResources(\n+                    pathResolver,\n+                    params.getProjectFilesystem(),\n+                    args.resources.get()),\n+                defaultJavacOptions.getGeneratedSourceFolderName(),\n+                args.labels.get(),\n+                args.contacts.get(),\n+                Optional.<SourcePath>absent(),\n+                new BuildTargetSourcePath(abiJarTarget),\n+                /* additionalClasspathEntries */ ImmutableSet.<Path>of(),\n+                args.testType.or(TestType.JUNIT),\n+                stepFactory,\n+                args.vmArgs.get(),\n+                ImmutableMap.<String, String>of(),\n+                validateAndGetSourcesUnderTest(\n+                    args.sourceUnderTest.get(),\n+                    params.getBuildTarget(),\n+                    resolver),\n+                Optional.<Path>absent(),\n+                Optional.<String>absent(),\n+                args.testRuleTimeoutMs.or(defaultTestRuleTimeoutMs),\n+                args.getRunTestSeparately(),\n+                args.stdOutLogLevel,\n+                args.stdErrLogLevel,\n+                testTempDirOverride));\n+\n+    resolver.addToIndex(\n+        CalculateAbi.of(\n+            abiJarTarget,\n+            pathResolver,\n+            params,\n+            new BuildTargetSourcePath(test.getBuildTarget())));\n+\n+    return test;\n+  }\n+\n+  public static ImmutableSet<BuildRule> validateAndGetSourcesUnderTest(\n+      ImmutableSet<BuildTarget> sourceUnderTestTargets,\n+      BuildTarget owner,\n+      BuildRuleResolver resolver) {\n+    ImmutableSet.Builder<BuildRule> sourceUnderTest = ImmutableSet.builder();\n+    for (BuildTarget target : sourceUnderTestTargets) {\n+      BuildRule rule = resolver.getRule(target);\n+      if (!(rule instanceof JavaLibrary)) {\n+        // In this case, the source under test specified in the build file was not a Java library\n+        // rule. Since EMMA requires the sources to be in Java, we will throw this exception and\n+        // not continue with the tests.\n+        throw new HumanReadableException(\n+            \"Specified source under test for %s is not a Java library: %s (%s).\",\n+            owner,\n+            rule.getFullyQualifiedName(),\n+            rule.getType());\n+      }\n+      sourceUnderTest.add(rule);\n+    }\n+    return sourceUnderTest.build();\n+  }\n+\n+  @SuppressFieldNotInitialized\n+  public static class Arg extends GroovyLibraryDescription.Arg {\n+    public Optional<ImmutableSortedSet<String>> contacts;\n+    public Optional<ImmutableSortedSet<Label>> labels;\n+    @Hint(isDep = false) public Optional<ImmutableSortedSet<BuildTarget>> sourceUnderTest;","path":"src/com/facebook/buck/jvm/groovy/GroovyTestDescription.java","position":181,"original_position":181,"commit_id":"1e8af8574c93b02da1248c5f99d2628d5bd88fe2","original_commit_id":"1e8af8574c93b02da1248c5f99d2628d5bd88fe2","user":{"login":"Coneko","id":1614903,"avatar_url":"https://avatars.githubusercontent.com/u/1614903?v=3","gravatar_id":"","url":"https://api.github.com/users/Coneko","html_url":"https://github.com/Coneko","followers_url":"https://api.github.com/users/Coneko/followers","following_url":"https://api.github.com/users/Coneko/following{/other_user}","gists_url":"https://api.github.com/users/Coneko/gists{/gist_id}","starred_url":"https://api.github.com/users/Coneko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Coneko/subscriptions","organizations_url":"https://api.github.com/users/Coneko/orgs","repos_url":"https://api.github.com/users/Coneko/repos","events_url":"https://api.github.com/users/Coneko/events{/privacy}","received_events_url":"https://api.github.com/users/Coneko/received_events","type":"User","site_admin":false},"body":"Remove `sourceUnderTest`. I assume you mirrored `java_test`'s interface, but this particular part of it causes issues in practice so we don't want to add it to new types of test targets.","created_at":"2016-01-16T14:30:06Z","updated_at":"2016-01-16T14:30:06Z","html_url":"https://github.com/facebook/buck/pull/617#discussion_r49932406","pull_request_url":"https://api.github.com/repos/facebook/buck/pulls/617","_links":{"self":{"href":"https://api.github.com/repos/facebook/buck/pulls/comments/49932406"},"html":{"href":"https://github.com/facebook/buck/pull/617#discussion_r49932406"},"pull_request":{"href":"https://api.github.com/repos/facebook/buck/pulls/617"}}},"pull_request":{"url":"https://api.github.com/repos/facebook/buck/pulls/617","id":56172520,"html_url":"https://github.com/facebook/buck/pull/617","diff_url":"https://github.com/facebook/buck/pull/617.diff","patch_url":"https://github.com/facebook/buck/pull/617.patch","issue_url":"https://api.github.com/repos/facebook/buck/issues/617","number":617,"state":"open","locked":false,"title":"Add groovy library description","user":{"login":"grumpyjames","id":100312,"avatar_url":"https://avatars.githubusercontent.com/u/100312?v=3","gravatar_id":"","url":"https://api.github.com/users/grumpyjames","html_url":"https://github.com/grumpyjames","followers_url":"https://api.github.com/users/grumpyjames/followers","following_url":"https://api.github.com/users/grumpyjames/following{/other_user}","gists_url":"https://api.github.com/users/grumpyjames/gists{/gist_id}","starred_url":"https://api.github.com/users/grumpyjames/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grumpyjames/subscriptions","organizations_url":"https://api.github.com/users/grumpyjames/orgs","repos_url":"https://api.github.com/users/grumpyjames/repos","events_url":"https://api.github.com/users/grumpyjames/events{/privacy}","received_events_url":"https://api.github.com/users/grumpyjames/received_events","type":"User","site_admin":false},"body":"Summary:\r\n\r\nAdd support for writing tests in groovy. Currently still only\r\nvia the junit runner, but that's fine, as almost everything supports\r\nthat anyway.\r\n\r\nTest-plan: CI (GroovyTestIntegrationTest is added)","created_at":"2016-01-15T14:05:56Z","updated_at":"2016-01-16T14:30:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c66e76436a7a5e86f971011c74e6a637b981ceac","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/facebook/buck/pulls/617/commits","review_comments_url":"https://api.github.com/repos/facebook/buck/pulls/617/comments","review_comment_url":"https://api.github.com/repos/facebook/buck/pulls/comments{/number}","comments_url":"https://api.github.com/repos/facebook/buck/issues/617/comments","statuses_url":"https://api.github.com/repos/facebook/buck/statuses/1e8af8574c93b02da1248c5f99d2628d5bd88fe2","head":{"label":"grumpyjames:feature/jvmlang-agnostic-18","ref":"feature/jvmlang-agnostic-18","sha":"1e8af8574c93b02da1248c5f99d2628d5bd88fe2","user":{"login":"grumpyjames","id":100312,"avatar_url":"https://avatars.githubusercontent.com/u/100312?v=3","gravatar_id":"","url":"https://api.github.com/users/grumpyjames","html_url":"https://github.com/grumpyjames","followers_url":"https://api.github.com/users/grumpyjames/followers","following_url":"https://api.github.com/users/grumpyjames/following{/other_user}","gists_url":"https://api.github.com/users/grumpyjames/gists{/gist_id}","starred_url":"https://api.github.com/users/grumpyjames/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grumpyjames/subscriptions","organizations_url":"https://api.github.com/users/grumpyjames/orgs","repos_url":"https://api.github.com/users/grumpyjames/repos","events_url":"https://api.github.com/users/grumpyjames/events{/privacy}","received_events_url":"https://api.github.com/users/grumpyjames/received_events","type":"User","site_admin":false},"repo":{"id":46117312,"name":"buck","full_name":"grumpyjames/buck","owner":{"login":"grumpyjames","id":100312,"avatar_url":"https://avatars.githubusercontent.com/u/100312?v=3","gravatar_id":"","url":"https://api.github.com/users/grumpyjames","html_url":"https://github.com/grumpyjames","followers_url":"https://api.github.com/users/grumpyjames/followers","following_url":"https://api.github.com/users/grumpyjames/following{/other_user}","gists_url":"https://api.github.com/users/grumpyjames/gists{/gist_id}","starred_url":"https://api.github.com/users/grumpyjames/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grumpyjames/subscriptions","organizations_url":"https://api.github.com/users/grumpyjames/orgs","repos_url":"https://api.github.com/users/grumpyjames/repos","events_url":"https://api.github.com/users/grumpyjames/events{/privacy}","received_events_url":"https://api.github.com/users/grumpyjames/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/grumpyjames/buck","description":"A fast build system that encourages the creation of small, reusable modules over a variety of platforms and languages.","fork":true,"url":"https://api.github.com/repos/grumpyjames/buck","forks_url":"https://api.github.com/repos/grumpyjames/buck/forks","keys_url":"https://api.github.com/repos/grumpyjames/buck/keys{/key_id}","collaborators_url":"https://api.github.com/repos/grumpyjames/buck/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/grumpyjames/buck/teams","hooks_url":"https://api.github.com/repos/grumpyjames/buck/hooks","issue_events_url":"https://api.github.com/repos/grumpyjames/buck/issues/events{/number}","events_url":"https://api.github.com/repos/grumpyjames/buck/events","assignees_url":"https://api.github.com/repos/grumpyjames/buck/assignees{/user}","branches_url":"https://api.github.com/repos/grumpyjames/buck/branches{/branch}","tags_url":"https://api.github.com/repos/grumpyjames/buck/tags","blobs_url":"https://api.github.com/repos/grumpyjames/buck/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/grumpyjames/buck/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/grumpyjames/buck/git/refs{/sha}","trees_url":"https://api.github.com/repos/grumpyjames/buck/git/trees{/sha}","statuses_url":"https://api.github.com/repos/grumpyjames/buck/statuses/{sha}","languages_url":"https://api.github.com/repos/grumpyjames/buck/languages","stargazers_url":"https://api.github.com/repos/grumpyjames/buck/stargazers","contributors_url":"https://api.github.com/repos/grumpyjames/buck/contributors","subscribers_url":"https://api.github.com/repos/grumpyjames/buck/subscribers","subscription_url":"https://api.github.com/repos/grumpyjames/buck/subscription","commits_url":"https://api.github.com/repos/grumpyjames/buck/commits{/sha}","git_commits_url":"https://api.github.com/repos/grumpyjames/buck/git/commits{/sha}","comments_url":"https://api.github.com/repos/grumpyjames/buck/comments{/number}","issue_comment_url":"https://api.github.com/repos/grumpyjames/buck/issues/comments{/number}","contents_url":"https://api.github.com/repos/grumpyjames/buck/contents/{+path}","compare_url":"https://api.github.com/repos/grumpyjames/buck/compare/{base}...{head}","merges_url":"https://api.github.com/repos/grumpyjames/buck/merges","archive_url":"https://api.github.com/repos/grumpyjames/buck/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/grumpyjames/buck/downloads","issues_url":"https://api.github.com/repos/grumpyjames/buck/issues{/number}","pulls_url":"https://api.github.com/repos/grumpyjames/buck/pulls{/number}","milestones_url":"https://api.github.com/repos/grumpyjames/buck/milestones{/number}","notifications_url":"https://api.github.com/repos/grumpyjames/buck/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/grumpyjames/buck/labels{/name}","releases_url":"https://api.github.com/repos/grumpyjames/buck/releases{/id}","created_at":"2015-11-13T11:07:25Z","updated_at":"2016-01-15T14:28:35Z","pushed_at":"2016-01-15T16:52:24Z","git_url":"git://github.com/grumpyjames/buck.git","ssh_url":"git@github.com:grumpyjames/buck.git","clone_url":"https://github.com/grumpyjames/buck.git","svn_url":"https://github.com/grumpyjames/buck","homepage":"http://buckbuild.com","size":333785,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"facebook:master","ref":"master","sha":"cc38dbee48d62ae9471fc7a86e432d131b72215a","user":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"repo":{"id":9504214,"name":"buck","full_name":"facebook/buck","owner":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/facebook/buck","description":"A fast build system that encourages the creation of small, reusable modules over a variety of platforms and languages.","fork":false,"url":"https://api.github.com/repos/facebook/buck","forks_url":"https://api.github.com/repos/facebook/buck/forks","keys_url":"https://api.github.com/repos/facebook/buck/keys{/key_id}","collaborators_url":"https://api.github.com/repos/facebook/buck/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/facebook/buck/teams","hooks_url":"https://api.github.com/repos/facebook/buck/hooks","issue_events_url":"https://api.github.com/repos/facebook/buck/issues/events{/number}","events_url":"https://api.github.com/repos/facebook/buck/events","assignees_url":"https://api.github.com/repos/facebook/buck/assignees{/user}","branches_url":"https://api.github.com/repos/facebook/buck/branches{/branch}","tags_url":"https://api.github.com/repos/facebook/buck/tags","blobs_url":"https://api.github.com/repos/facebook/buck/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/facebook/buck/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/facebook/buck/git/refs{/sha}","trees_url":"https://api.github.com/repos/facebook/buck/git/trees{/sha}","statuses_url":"https://api.github.com/repos/facebook/buck/statuses/{sha}","languages_url":"https://api.github.com/repos/facebook/buck/languages","stargazers_url":"https://api.github.com/repos/facebook/buck/stargazers","contributors_url":"https://api.github.com/repos/facebook/buck/contributors","subscribers_url":"https://api.github.com/repos/facebook/buck/subscribers","subscription_url":"https://api.github.com/repos/facebook/buck/subscription","commits_url":"https://api.github.com/repos/facebook/buck/commits{/sha}","git_commits_url":"https://api.github.com/repos/facebook/buck/git/commits{/sha}","comments_url":"https://api.github.com/repos/facebook/buck/comments{/number}","issue_comment_url":"https://api.github.com/repos/facebook/buck/issues/comments{/number}","contents_url":"https://api.github.com/repos/facebook/buck/contents/{+path}","compare_url":"https://api.github.com/repos/facebook/buck/compare/{base}...{head}","merges_url":"https://api.github.com/repos/facebook/buck/merges","archive_url":"https://api.github.com/repos/facebook/buck/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/facebook/buck/downloads","issues_url":"https://api.github.com/repos/facebook/buck/issues{/number}","pulls_url":"https://api.github.com/repos/facebook/buck/pulls{/number}","milestones_url":"https://api.github.com/repos/facebook/buck/milestones{/number}","notifications_url":"https://api.github.com/repos/facebook/buck/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/facebook/buck/labels{/name}","releases_url":"https://api.github.com/repos/facebook/buck/releases{/id}","created_at":"2013-04-17T18:12:18Z","updated_at":"2016-01-16T13:59:20Z","pushed_at":"2016-01-15T19:45:01Z","git_url":"git://github.com/facebook/buck.git","ssh_url":"git@github.com:facebook/buck.git","clone_url":"https://github.com/facebook/buck.git","svn_url":"https://github.com/facebook/buck","homepage":"https://buckbuild.com","size":365729,"stargazers_count":2231,"watchers_count":2231,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":378,"mirror_url":null,"open_issues_count":92,"forks":378,"open_issues":92,"watchers":2231,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/facebook/buck/pulls/617"},"html":{"href":"https://github.com/facebook/buck/pull/617"},"issue":{"href":"https://api.github.com/repos/facebook/buck/issues/617"},"comments":{"href":"https://api.github.com/repos/facebook/buck/issues/617/comments"},"review_comments":{"href":"https://api.github.com/repos/facebook/buck/pulls/617/comments"},"review_comment":{"href":"https://api.github.com/repos/facebook/buck/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/facebook/buck/pulls/617/commits"},"statuses":{"href":"https://api.github.com/repos/facebook/buck/statuses/1e8af8574c93b02da1248c5f99d2628d5bd88fe2"}}}}