Skip to content

sudir/verify

Repository files navigation

verify - v0.0.1

Validate language syntax for unit testing along with added Chef features for custom resources.
Compatible with python 2.7 above

Basic Overview

Verify License Sulayman Touray Code Gaurantee

    Required Prerequisites
  • For any bash or python scripts under validation, ensure the proper shebang is declared within script
  • For any custom written Chef recipe under validation, do not mix custom language resources within the same recipe

Using verify is easy, simply download verify, assign executable permissions and move it to /usr/loca/bin,
you can begin by typing verify --help to get started.
Declared logic within functions called from Menu arguments for ex:
# run tests on native scripts
parser.add_argument("-b", "--bash", action="store_true",    help="validate native bash scripts")



# Function to match
def bash_native(fileinput, absolutepaths):  
  with open(fileinput) as codefile:
    if '#!/bin/bash' in codefile.read():
         # If no error is found?
         FNULL = open(os.devnull, 'w')
         resout=subprocess.Popen("bash -n " + fileinput, shell=True, stderr=subprocess.PIPE, stdout=FNULL)
         out, err = resout.communicate()
         if err == "":
          print('Pass, no bash syntax errors detected for:'+' '+fileinput)
         else:
         # If theres a problem, tell me what it is
          with open(fileinput+'.testcase','w') as codefile:
           subprocess.call('echo Test case report inititated $(date) '+'\n'+"echo Fail, bash syntax errors detected for: "+ fileinput+"\n"+"bash -n " + fileinput, shell=True, stderr=codefile, stdout=codefile)
          with open(fileinput+'.testcase', 'r') as aiostream:
           print aiostream.read()

More to come soon....
Invented By: Sulayman Touray

About

App developed for Syntax Checking

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published