Fix soong for go test ./...
Fix various issues that prevent building or running tests with the
Go tools:
Remove testing/test_spec_proto/go.mod. There's already a go.mod at
the top level, and adding testing/test_spec_proto/go.mod breaks
compiling with the Go tools in IntelliJ or from the command line.
Fix go vet issues when trying to print []DataPath.
Fix aconfig_conversion_test.go and add it to Android.bp so it runs
in presubmit.
Test: go test ./...
Change-Id: I18af2f05631446fe507744a2951e4b02c7ab59be
diff --git a/bp2build/Android.bp b/bp2build/Android.bp
index 14e32ed..64ee01f 100644
--- a/bp2build/Android.bp
+++ b/bp2build/Android.bp
@@ -6,6 +6,7 @@
name: "soong-bp2build",
pkgPath: "android/soong/bp2build",
srcs: [
+ "aconfig_conversion_test.go",
"androidbp_to_build_templates.go",
"bp2build.go",
"bp2build_product_config.go",
@@ -21,6 +22,7 @@
deps: [
"blueprint-bootstrap",
"soong-aidl-library",
+ "soong-aconfig",
"soong-android",
"soong-android-allowlists",
"soong-android-soongconfig",
diff --git a/bp2build/aconfig_conversion_test.go b/bp2build/aconfig_conversion_test.go
index ca41680..d6e20df 100644
--- a/bp2build/aconfig_conversion_test.go
+++ b/bp2build/aconfig_conversion_test.go
@@ -156,7 +156,7 @@
name: "foo",
aconfig_declarations: "foo_aconfig_declarations",
libs: ["foo_java_library"],
- test: true,
+ mode: "test",
}
`
expectedBazelTargets := []string{
@@ -184,7 +184,6 @@
AttrNameToString{
"aconfig_declarations": `":foo_aconfig_declarations"`,
"libs": `[":foo_java_library-neverlink"]`,
- "test": `True`,
"sdk_version": `"system_current"`,
"target_compatible_with": `["//build/bazel_common_rules/platforms/os:android"]`,
},
@@ -213,7 +212,7 @@
java_aconfig_library {
name: "foo_aconfig_library",
aconfig_declarations: "foo_aconfig_declarations",
- test: true,
+ mode: "test",
}
`
expectedBazelTargets := []string{
@@ -230,7 +229,6 @@
"foo_aconfig_library",
AttrNameToString{
"aconfig_declarations": `":foo_aconfig_declarations"`,
- "test": `True`,
"sdk_version": `"system_current"`,
"target_compatible_with": `["//build/bazel_common_rules/platforms/os:android"]`,
},
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 794c5ee..e2dba90 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -720,7 +720,7 @@
return
}
if len(testBinary.dataPaths()) != 1 {
- t.Errorf("expected exactly one test data file. test data files: [%s]", testBinary.dataPaths())
+ t.Errorf("expected exactly one test data file. test data files: [%v]", testBinary.dataPaths())
return
}
@@ -777,7 +777,7 @@
t.Fatalf("expected exactly one output file. output files: [%s]", outputFiles)
}
if len(testBinary.dataPaths()) != 2 {
- t.Fatalf("expected exactly one test data file. test data files: [%s]", testBinary.dataPaths())
+ t.Fatalf("expected exactly one test data file. test data files: [%v]", testBinary.dataPaths())
}
outputPath := outputFiles[0].String()
@@ -3332,7 +3332,7 @@
t.Errorf("expected exactly one output file. output files: [%s]", outputFiles)
}
if len(testBinary.dataPaths()) != 1 {
- t.Errorf("expected exactly one test data file. test data files: [%s]", testBinary.dataPaths())
+ t.Errorf("expected exactly one test data file. test data files: [%v]", testBinary.dataPaths())
}
outputPath := outputFiles[0].String()
diff --git a/rust/test_test.go b/rust/test_test.go
index 8906f1c..6d0ebcf 100644
--- a/rust/test_test.go
+++ b/rust/test_test.go
@@ -38,7 +38,7 @@
dataPaths := testingModule.Module().(*Module).compiler.(*testDecorator).dataPaths()
if len(dataPaths) != 1 {
- t.Errorf("expected exactly one test data file. test data files: [%s]", dataPaths)
+ t.Errorf("expected exactly one test data file. test data files: [%v]", dataPaths)
return
}
}
@@ -116,7 +116,7 @@
t.Fatalf("expected exactly one output file. output files: [%s]", outputFiles)
}
if len(testBinary.dataPaths()) != 2 {
- t.Fatalf("expected exactly two test data files. test data files: [%s]", testBinary.dataPaths())
+ t.Fatalf("expected exactly two test data files. test data files: [%v]", testBinary.dataPaths())
}
outputPath := outputFiles[0].String()
@@ -178,7 +178,7 @@
t.Fatalf("expected exactly one output file. output files: [%s]", outputFiles)
}
if len(testBinary.dataPaths()) != 3 {
- t.Fatalf("expected exactly two test data files. test data files: [%s]", testBinary.dataPaths())
+ t.Fatalf("expected exactly two test data files. test data files: [%v]", testBinary.dataPaths())
}
outputPath := outputFiles[0].String()
diff --git a/testing/test_spec_proto/go.mod b/testing/test_spec_proto/go.mod
deleted file mode 100644
index 482cdbb..0000000
--- a/testing/test_spec_proto/go.mod
+++ /dev/null
@@ -1,2 +0,0 @@
-module test_spec_proto
-go 1.18
\ No newline at end of file