From 484cf33b97c868ddc823ad1b781448a85b53bad9 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Sun, 1 Oct 2023 17:53:16 +0300 Subject: [PATCH] Add option --barcode/-B for printing unique barcode for test --- README.md | 2 ++ cli/cli.go | 14 ++++++++++---- cli/executor/validators.go | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8c47d210..675d5f70 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,8 @@ Options --list-packages, -L List required packages --list-packages-flat, -L1 List required packages in one line (useful for scripts) --variables, -V List recipe variables + --barcode, -B Show unique barcode for test (based on recipe and required packages) + --time, -T Print execution time for every action --format, -f format Output format (tap13|tap14|json|xml) --dir, -d dir Path to working directory --path, -p path Path to directory with binaries diff --git a/cli/cli.go b/cli/cli.go index c3bc4cca..d18afd4e 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -51,6 +51,7 @@ const ( OPT_LIST_PACKAGES = "L:list-packages" OPT_LIST_PACKAGES_FLAT = "L1:list-packages-flat" OPT_VARIABLES = "V:variables" + OPT_BARCODE = "B:barcode" OPT_TIME = "T:time" OPT_FORMAT = "f:format" OPT_DIR = "d:dir" @@ -76,6 +77,7 @@ var optMap = options.Map{ OPT_LIST_PACKAGES: {Type: options.BOOL}, OPT_LIST_PACKAGES_FLAT: {Type: options.BOOL}, OPT_VARIABLES: {Type: options.BOOL}, + OPT_BARCODE: {Type: options.BOOL}, OPT_TIME: {Type: options.BOOL}, OPT_FORMAT: {}, OPT_DIR: {}, @@ -257,14 +259,17 @@ func process(file string) { r.Dir, _ = filepath.Abs(filepath.Dir(file)) } - if options.GetB(OPT_LIST_PACKAGES) || options.GetB(OPT_LIST_PACKAGES_FLAT) { + switch { + case options.GetB(OPT_LIST_PACKAGES), + options.GetB(OPT_LIST_PACKAGES_FLAT): listPackages(r.Packages) os.Exit(0) - } - - if options.GetB(OPT_VARIABLES) { + case options.GetB(OPT_VARIABLES): listVariables(r) os.Exit(0) + case options.GetB(OPT_BARCODE): + printBarcode(r) + os.Exit(0) } if options.Has(OPT_ERROR_DIR) { @@ -454,6 +459,7 @@ func genUsage() *usage.Info { info.AddOption(OPT_LIST_PACKAGES, "List required packages") info.AddOption(OPT_LIST_PACKAGES_FLAT, "List required packages in one line {s-}(useful for scripts){!}") info.AddOption(OPT_VARIABLES, "List recipe variables") + info.AddOption(OPT_BARCODE, "Show unique barcode for test {s-}(based on recipe and required packages){!}") info.AddOption(OPT_TIME, "Print execution time for every action") info.AddOption(OPT_FORMAT, "Output format {s-}(tap13|tap14|json|xml){!}", "format") info.AddOption(OPT_DIR, "Path to working directory", "dir") diff --git a/cli/executor/validators.go b/cli/executor/validators.go index 89ae1dcc..a4393ad9 100644 --- a/cli/executor/validators.go +++ b/cli/executor/validators.go @@ -174,7 +174,7 @@ func checkRPMPackages(pkgs []string) []error { var errs []error for _, pkgInfo := range strings.Split(string(output), "\n") { - if strings.Contains(pkgInfo, "is not installed") { + if strings.Contains(pkgInfo, " ") { pkgName := strutil.ReadField(pkgInfo, 1, true) errs = append(errs, fmt.Errorf("Package %s is not installed", pkgName)) }