Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9f6a0f1d authored by Aditya Choudhary's avatar Aditya Choudhary
Browse files

Metadata tool correction: Output empty proto in case of no input

Ignore-AOSP-First: CPing test_spec rule to udc-mainline-prod to support migration of test targets. Cherry pick of:aosp/2906355

Change-Id: I85ca22574433ab164c303c1f6b0d29191e704cbb
Merged-In: I85ca22574433ab164c303c1f6b0d29191e704cbb
parent 8f986c3f
Loading
Loading
Loading
Loading
+19 −10
Original line number Diff line number Diff line
@@ -77,9 +77,18 @@ func readFileToString(filePath string) string {
	return string(data)
}

func writeNewlineToOutputFile(outputFile string) {
func writeEmptyOutputProto(outputFile string, metadataRule string) {
	file, err := os.Create(outputFile)
	data := "\n"
	if err != nil {
		log.Fatal(err)
	}
	var message proto.Message
	if metadataRule == "test_spec" {
		message = &test_spec_proto.TestSpec{}
	} else if metadataRule == "code_metadata" {
		message = &code_metadata_proto.CodeMetadata{}
	}
	data, err := proto.Marshal(message)
	if err != nil {
		log.Fatal(err)
	}
@@ -235,7 +244,7 @@ func main() {
	inputFileData := strings.TrimRight(readFileToString(*inputFile), "\n")
	filePaths := strings.Split(inputFileData, " ")
	if len(filePaths) == 1 && filePaths[0] == "" {
		writeNewlineToOutputFile(*outputFile)
		writeEmptyOutputProto(*outputFile, *rule)
		return
	}
	ownershipMetadataMap := &sync.Map{}
+0 −1
Original line number Diff line number Diff line