mirror of
https://github.com/kubescape/kubescape.git
synced 2026-04-15 06:58:11 +00:00
use command
This commit is contained in:
@@ -1,34 +1,14 @@
|
||||
import platform
|
||||
from os import path
|
||||
from sys import stderr
|
||||
|
||||
|
||||
def get_build_dir():
|
||||
current_platform = platform.system()
|
||||
build_dir = "build/"
|
||||
|
||||
if current_platform == "Windows": build_dir += "windows-latest"
|
||||
elif current_platform == "Linux": build_dir += "ubuntu-latest"
|
||||
elif current_platform == "Darwin": build_dir += "macos-latest"
|
||||
else: raise OSError(f"Platform {current_platform} is not supported!")
|
||||
|
||||
return build_dir
|
||||
|
||||
|
||||
def get_package_name():
|
||||
return "kubescape"
|
||||
|
||||
|
||||
def get_bin_cli():
|
||||
return path.abspath(path.join(get_build_dir(), get_package_name()))
|
||||
|
||||
|
||||
def check_status(status, msg):
|
||||
if status != 0:
|
||||
stderr.write(msg)
|
||||
exit(status)
|
||||
import subprocess
|
||||
|
||||
|
||||
def get_exec_from_args(args: list):
|
||||
return args[1]
|
||||
|
||||
|
||||
def run_command(command):
|
||||
try:
|
||||
return str(subprocess.check_output(command))
|
||||
except Exception as e:
|
||||
return e
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import subprocess
|
||||
import smoke_utils
|
||||
import sys
|
||||
|
||||
@@ -6,7 +5,7 @@ import sys
|
||||
def test_command(command: list):
|
||||
print(f"Testing \"{' '.join(command[1:])}\" command")
|
||||
|
||||
msg = str(subprocess.check_output(command))
|
||||
msg = smoke_utils.run_command(command)
|
||||
assert "unknown command" not in msg, f"{command[1:]} is missing: {msg}"
|
||||
assert "invalid parameter" not in msg, f"{command[1:]} is invalid: {msg}"
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@ import smoke_utils
|
||||
import sys
|
||||
|
||||
|
||||
def run(kubescape_exec:str):
|
||||
def run(kubescape_exec: str):
|
||||
print("Testing version")
|
||||
|
||||
ver = os.getenv("RELEASE")
|
||||
msg = str(subprocess.check_output([kubescape_exec, "version"]))
|
||||
msg = smoke_utils.run_command(command=[kubescape_exec, "version"])
|
||||
assert ver in msg, f"expected version: {ver}, found: {msg}"
|
||||
|
||||
print("Done testing version")
|
||||
|
||||
Reference in New Issue
Block a user