From 8736ce29e8cda85924fa2f083a1421afed965bb2 Mon Sep 17 00:00:00 2001 From: Zoran Jovanovic Date: Tue, 21 Aug 2018 17:10:29 +0200 Subject: Enable kotlinc flags in blueprint files Add support for adding kotlinc files in the module. Some flags are unnecessary as they are added by default (-no-jdk and -no-stdlib), or are not needed on an Android build (-include-runtime), or may conflict with the build (-kotlin-home and -Xintellij-plugin-root), so the error stops the build if they are added. Test: part of java/java_test.go Change-Id: If3b2777062daaa490a20c014e9b1bb4b1cb0a8df Signed-off-by: Zoran Jovanovic --- java/java_test.go | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'java/java_test.go') diff --git a/java/java_test.go b/java/java_test.go index 86349fe67..4d4b83618 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -1124,3 +1124,64 @@ func TestJavaSdkLibrary(t *testing.T) { } } } + +var compilerFlagsTestCases = []struct { + in string + out bool +}{ + { + in: "a", + out: false, + }, + { + in: "-a", + out: true, + }, + { + in: "-no-jdk", + out: false, + }, + { + in: "-no-stdlib", + out: false, + }, + { + in: "-kotlin-home", + out: false, + }, + { + in: "-kotlin-home /some/path", + out: false, + }, + { + in: "-include-runtime", + out: false, + }, + { + in: "-Xintellij-plugin-root", + out: false, + }, +} + +type mockContext struct { + android.ModuleContext + result bool +} + +func (ctx *mockContext) PropertyErrorf(property, format string, args ...interface{}) { + // CheckBadCompilerFlags calls this function when the flag should be rejected + ctx.result = false +} + +func TestCompilerFlags(t *testing.T) { + for _, testCase := range compilerFlagsTestCases { + ctx := &mockContext{result: true} + CheckKotlincFlags(ctx, []string{testCase.in}) + if ctx.result != testCase.out { + t.Errorf("incorrect output:") + t.Errorf(" input: %#v", testCase.in) + t.Errorf(" expected: %#v", testCase.out) + t.Errorf(" got: %#v", ctx.result) + } + } +} -- cgit v1.2.3-59-g8ed1b