-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement coverage target support (#109)
* Implement coverage target support
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/daedaleanai/cobra" | ||
) | ||
|
||
var coverageCmd = &cobra.Command{ | ||
Use: "coverage [patterns] [build flags] [: test args]", | ||
Short: "Builds, tests the targets and generate coverage report.", | ||
Long: `Builds, tests the targets and generate coverage report.`, | ||
Run: runCoverage, | ||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { | ||
return completeBuildArgs(toComplete, modeCoverage), cobra.ShellCompDirectiveNoFileComp | ||
}, | ||
DisableFlagsInUseLine: true, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(coverageCmd) | ||
coverageCmd.Flags().SetInterspersed(false) | ||
} | ||
|
||
func runCoverage(cmd *cobra.Command, args []string) { | ||
testArgs := []string{} | ||
buildArgs := args | ||
for idx, arg := range args { | ||
if arg == ":" { | ||
testArgs = args[idx+1:] | ||
buildArgs = args[:idx] | ||
break | ||
} | ||
} | ||
runBuild(buildArgs, modeCoverage, testArgs) | ||
} |