Loading tools/metadata/OWNERS 0 → 100644 +4 −0 Original line number Diff line number Diff line dariofreni@google.com joeo@google.com ronish@google.com caditya@google.com tools/metadata/generator.go +28 −20 Original line number Diff line number Diff line Loading @@ -73,7 +73,7 @@ func readFileToString(filePath string) string { return string(data) } func processProtobuf( func processTestSpecProtobuf( filePath string, ownershipMetadataMap *sync.Map, keyLocks *keyToLocksMap, errCh chan error, wg *sync.WaitGroup, ) { Loading Loading @@ -130,10 +130,11 @@ func processProtobuf( func main() { inputFile := flag.String("inputFile", "", "Input file path") outputFile := flag.String("outputFile", "", "Output file path") rule := flag.String("rule", "", "Metadata rule (Hint: test_spec or code_metadata)") flag.Parse() if *inputFile == "" || *outputFile == "" { fmt.Println("Usage: metadata -inputFile <input file path> -outputFile <output file path>") if *inputFile == "" || *outputFile == "" || *rule == "" { fmt.Println("Usage: metadata -rule <rule> -inputFile <input file path> -outputFile <output file path>") os.Exit(1) } Loading @@ -144,9 +145,11 @@ func main() { errCh := make(chan error, len(filePaths)) var wg sync.WaitGroup switch *rule { case "test_spec": for _, filePath := range filePaths { wg.Add(1) go processProtobuf(filePath, ownershipMetadataMap, keyLocks, errCh, &wg) go processTestSpecProtobuf(filePath, ownershipMetadataMap, keyLocks, errCh, &wg) } wg.Wait() Loading @@ -166,4 +169,9 @@ func main() { } writeOutput(*outputFile, allMetadata) break case "code_metadata": default: log.Fatalf("No specific processing implemented for rule '%s'.\n", *rule) } } tools/metadata/testdata/metadata_test.go +2 −2 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ import ( func TestMetadata(t *testing.T) { cmd := exec.Command( "metadata", "-inputFile", "./inputFiles.txt", "-outputFile", "metadata", "-rule", "test_spec", "-inputFile", "./inputFiles.txt", "-outputFile", "./generatedOutputFile.txt", ) stderr, err := cmd.CombinedOutput() Loading Loading @@ -40,7 +40,7 @@ func TestMetadata(t *testing.T) { func TestMetadataNegativeCase(t *testing.T) { cmd := exec.Command( "metadata", "-inputFile", "./inputFilesNegativeCase.txt", "-outputFile", "metadata", "-rule", "test_spec", "-inputFile", "./inputFilesNegativeCase.txt", "-outputFile", "./generatedOutputFileNegativeCase.txt", ) stderr, err := cmd.CombinedOutput() Loading Loading
tools/metadata/OWNERS 0 → 100644 +4 −0 Original line number Diff line number Diff line dariofreni@google.com joeo@google.com ronish@google.com caditya@google.com
tools/metadata/generator.go +28 −20 Original line number Diff line number Diff line Loading @@ -73,7 +73,7 @@ func readFileToString(filePath string) string { return string(data) } func processProtobuf( func processTestSpecProtobuf( filePath string, ownershipMetadataMap *sync.Map, keyLocks *keyToLocksMap, errCh chan error, wg *sync.WaitGroup, ) { Loading Loading @@ -130,10 +130,11 @@ func processProtobuf( func main() { inputFile := flag.String("inputFile", "", "Input file path") outputFile := flag.String("outputFile", "", "Output file path") rule := flag.String("rule", "", "Metadata rule (Hint: test_spec or code_metadata)") flag.Parse() if *inputFile == "" || *outputFile == "" { fmt.Println("Usage: metadata -inputFile <input file path> -outputFile <output file path>") if *inputFile == "" || *outputFile == "" || *rule == "" { fmt.Println("Usage: metadata -rule <rule> -inputFile <input file path> -outputFile <output file path>") os.Exit(1) } Loading @@ -144,9 +145,11 @@ func main() { errCh := make(chan error, len(filePaths)) var wg sync.WaitGroup switch *rule { case "test_spec": for _, filePath := range filePaths { wg.Add(1) go processProtobuf(filePath, ownershipMetadataMap, keyLocks, errCh, &wg) go processTestSpecProtobuf(filePath, ownershipMetadataMap, keyLocks, errCh, &wg) } wg.Wait() Loading @@ -166,4 +169,9 @@ func main() { } writeOutput(*outputFile, allMetadata) break case "code_metadata": default: log.Fatalf("No specific processing implemented for rule '%s'.\n", *rule) } }
tools/metadata/testdata/metadata_test.go +2 −2 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ import ( func TestMetadata(t *testing.T) { cmd := exec.Command( "metadata", "-inputFile", "./inputFiles.txt", "-outputFile", "metadata", "-rule", "test_spec", "-inputFile", "./inputFiles.txt", "-outputFile", "./generatedOutputFile.txt", ) stderr, err := cmd.CombinedOutput() Loading Loading @@ -40,7 +40,7 @@ func TestMetadata(t *testing.T) { func TestMetadataNegativeCase(t *testing.T) { cmd := exec.Command( "metadata", "-inputFile", "./inputFilesNegativeCase.txt", "-outputFile", "metadata", "-rule", "test_spec", "-inputFile", "./inputFilesNegativeCase.txt", "-outputFile", "./generatedOutputFileNegativeCase.txt", ) stderr, err := cmd.CombinedOutput() Loading