diff options
author | 2019-01-18 15:05:09 -0800 | |
---|---|---|
committer | 2019-01-22 16:32:11 +0000 | |
commit | 21fc9bbe198caf9736bb9dc0f5701e8bfd56de40 (patch) | |
tree | e946fd278efb789be91debe6b037c3009a59a9b3 /java/kotlin_test.go | |
parent | f8c06c159e8ba3fa7afdc263d72f91cbd50a9e36 (diff) |
Move kotlin to it's own file
kapt is going to make kotlin a little more complicated, move the
rules and tests to their own files.
Bug: 122251693
Test: m checkbuild
Change-Id: Ieed78b97995ced210b710bd50c357514cc8e3bc6
Diffstat (limited to 'java/kotlin_test.go')
-rw-r--r-- | java/kotlin_test.go | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/java/kotlin_test.go b/java/kotlin_test.go new file mode 100644 index 000000000..08a308515 --- /dev/null +++ b/java/kotlin_test.go @@ -0,0 +1,82 @@ +// Copyright 2017 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package java + +import ( + "strings" + "testing" +) + +func TestKotlin(t *testing.T) { + ctx := testJava(t, ` + java_library { + name: "foo", + srcs: ["a.java", "b.kt"], + } + + java_library { + name: "bar", + srcs: ["b.kt"], + libs: ["foo"], + static_libs: ["baz"], + } + + java_library { + name: "baz", + srcs: ["c.java"], + } + `) + + fooKotlinc := ctx.ModuleForTests("foo", "android_common").Rule("kotlinc") + fooJavac := ctx.ModuleForTests("foo", "android_common").Rule("javac") + fooJar := ctx.ModuleForTests("foo", "android_common").Output("combined/foo.jar") + + if len(fooKotlinc.Inputs) != 2 || fooKotlinc.Inputs[0].String() != "a.java" || + fooKotlinc.Inputs[1].String() != "b.kt" { + t.Errorf(`foo kotlinc inputs %v != ["a.java", "b.kt"]`, fooKotlinc.Inputs) + } + + if len(fooJavac.Inputs) != 1 || fooJavac.Inputs[0].String() != "a.java" { + t.Errorf(`foo inputs %v != ["a.java"]`, fooJavac.Inputs) + } + + if !strings.Contains(fooJavac.Args["classpath"], fooKotlinc.Output.String()) { + t.Errorf("foo classpath %v does not contain %q", + fooJavac.Args["classpath"], fooKotlinc.Output.String()) + } + + if !inList(fooKotlinc.Output.String(), fooJar.Inputs.Strings()) { + t.Errorf("foo jar inputs %v does not contain %q", + fooJar.Inputs.Strings(), fooKotlinc.Output.String()) + } + + fooHeaderJar := ctx.ModuleForTests("foo", "android_common").Output("turbine-combined/foo.jar") + bazHeaderJar := ctx.ModuleForTests("baz", "android_common").Output("turbine-combined/baz.jar") + barKotlinc := ctx.ModuleForTests("bar", "android_common").Rule("kotlinc") + + if len(barKotlinc.Inputs) != 1 || barKotlinc.Inputs[0].String() != "b.kt" { + t.Errorf(`bar kotlinc inputs %v != ["b.kt"]`, barKotlinc.Inputs) + } + + if !inList(fooHeaderJar.Output.String(), barKotlinc.Implicits.Strings()) { + t.Errorf(`expected %q in bar implicits %v`, + fooHeaderJar.Output.String(), barKotlinc.Implicits.Strings()) + } + + if !inList(bazHeaderJar.Output.String(), barKotlinc.Implicits.Strings()) { + t.Errorf(`expected %q in bar implicits %v`, + bazHeaderJar.Output.String(), barKotlinc.Implicits.Strings()) + } +} |