def check_cyclomatic_complexity():
    """
    checks the repo for function with cyclomatic complexity , fails if value is greater than 6
    """
    call_subprocess("python -m lizard similarity -X> CC.xml")
    call_subprocess("python build_scripts/cyclo_gate.py --c 6")
    print("Stage cyclomatic complexity detection -- COMPLETED & PASSED  --")
コード例 #2
0
def install_pip():
    """
    Installs the dependent packages
    """
    pip_install_txt = os.path.join(os.path.abspath(os.path.join(__file__, os.pardir)), "build_test_dependencies.txt")
    call_subprocess("python -m pip install -r %s" % pip_install_txt)
    print("Stage install dependencies -- COMPLETED --")
def check_lint():
    """
    function check the repo for any python linting errors
    """
    call_subprocess(
        "python3 -m pylint functiondefextractor/ test/ build_scripts/ ")
    print("Stage linting -- COMPLETED & PASSED  --")
def mutation_pass_fail_check():
    """ Gates mutation test for 20 percentage """
    call_subprocess(
        "mutmut junitxml --suspicious-policy=ignore --untested-policy=ignore > mutmut.xml"
    )
    call_subprocess("python build_scripts/mutmut_parse.py --m 20")
    print("Stage mutation testing -- COMPLETED & PASSED  --")
def check_dead_code():
    """
    checks the repo for dead code with minimum confidence 70
    """
    call_subprocess("python -m vulture --min-confidence 70 "
                    "eaglevision test build_scripts whitelist.py")
    print("Stage dead code detection -- COMPLETED & PASSED  --")
def test_coverage():
    """
    executes the tests and gates the coverage for greater than 95
    """
    call_subprocess(
        'python3 -m pytest test --cov-config=.coveragerc --cov-report "html" --cov=functiondefextractor'
    )
    call_subprocess("coverage report --fail-under=95")
    print("Stage test & coverage -- COMPLETED & PASSED --")
def check_code_duplication():
    """
    checks the repo for any duplicate or code code with 20 token and 10% allowed duplicate
    """
    call_subprocess(
        'jscpd --min-tokens 20 --reporters "json" --mode "strict" --format "python" -o . .'
    )
    call_subprocess("python build_scripts/jscpd_parser.py --j 10 ")
    print("Stage duplicate detection -- COMPLETED & PASSED  --")
def install_aspell():
    """
    Installs Aspell and configure for english
    """
    if str(platform.system()).upper() == "LINUX":
        call_subprocess("sudo apt-get update -qq")
        call_subprocess("sudo apt-get install --assume-yes aspell aspell-en")
        print("Stage Install aspell -- COMPLETED & PASSED --")
    else:
        print("Please install and configure Aspell for english")
def install_ctags_package():
    """
    Installs ctags and configure it
    """
    if str(platform.system()).upper() == "LINUX":
        call_subprocess("sudo apt-get install ctags")
        call_subprocess('export PATH="$PATH:/usr/bin/ctags"')
        print("Stage Install ctags -- COMPLETED & PASSED --")
    else:
        print("Please install and configure ctags")
コード例 #10
0
 def test_execute_sanity_suite(self):
     """
     Function which executes the sanity test
     """
     input_file = os.path.join(
         os.path.abspath(os.path.join(__file__, os.pardir, os.pardir)),
         "test_resource", "Testcases.xlsx")
     call_subprocess(
         'python -m similarity --p "%s" --u 0 --c "1,2" --n "8"' %
         input_file)
     self.verify_func_obj.verify_functional_test()
     print("Sanity test is COMPLETED & PASSED")
def install_npm_packages():
    """
    Installs jscpd and configure for english
    """
    if str(platform.system()).upper() == "LINUX":
        call_subprocess("sudo npm install")
        call_subprocess("sudo npm install -g [email protected]")
        call_subprocess("sudo npm i -g [email protected]")
        call_subprocess("sudo npm i -g [email protected]")
        print(
            "Stage Install jscpd, markdownlint & ymllint -- COMPLETED & PASSED --"
        )
    else:
        print("Please install and configure jscpd, markdownlint & ymllint")
コード例 #12
0
def run_performance_test(time_perf):
    """ Function used to run the test to check how much time similarity tool takes to execute"""
    input_file = os.path.join(os.path.abspath(os.path.join(__file__, os.pardir)), "input_data.xlsx")
    input_count = get_last_line_file(input_file)
    if not os.path.exists(input_file):
        print("input file is not generated")
        sys.exit(1)
    time0 = time.time()
    call_subprocess('python -m similarity --p "%s"'
                    ' --u 0 --c "1" --r "50,100" --f "1030000"' % input_file)
    time1 = time.time()
    execution_time = time1 - time0
    out_file = os.path.join(os.path.abspath(os.path.join(__file__, os.pardir)),
                            "input_data_recommendation_%s.xlsx" % str(find_last_outfile()))
    out_count = get_last_line_file(out_file)
    print("Total time taken to analyse %s input data is %s sec and generated %s combination match " % (input_count,
                                                                                                       execution_time,
                                                                                                       out_count))
    file_out = open(os.path.join(os.path.dirname(os.path.abspath(os.path.join(__file__, os.pardir))), "perfo.txt"), 'w')
    file_out.write(
        "Total time taken to analyse %s input data is %s sec Vs bench mark %s sec and generated %s combination match "
        % (input_count, execution_time, (time_perf * input_count), out_count))
    file_out.close()
    validate_perfo(execution_time, input_count, time_perf)
def mutation_testing():
    """
    executes the mutation tests and gates for 20 percentage
    """
    call_subprocess("python3 -m mutmut run > mutmut.log || true")
    call_subprocess(
        "mutmut junitxml --suspicious-policy=ignore --untested-policy=ignore > mutmut.xml"
    )
    call_subprocess("python3 build_scripts/mutmut_parse.py --m 20")
    print("Stage mutation testing -- COMPLETED & PASSED  --")
def test_coverage():
    """
    executes the tests and gates the coverage for greater than 95
    """
    call_subprocess(
        'python -m pytest test --capture=sys --cov-config=.coveragerc --cov-report "html" '
        '--cov=eaglevision')
    call_subprocess("coverage report --fail-under=95")
    call_subprocess("codecov")
    print("Stage test & coverage -- COMPLETED & PASSED --")
コード例 #15
0
 def test_execute_sanity_suite(self):
     """
     Function which executes the sanity test
     """
     input_file = os.path.join(self.file_path, "test_resource", "test_repo")
     call_subprocess("sudo apt-get install ctags")
     call_subprocess('export PATH="$PATH:/usr/bin/ctags"')
     call_subprocess(
         'python3 -m functiondefextractor.extractor_cmd --p "%s"' %
         input_file)
     self.verify_func_obj.verify_functional_test()
     print("Sanity test is COMPLETED & PASSED")
def check_md_linting():
    """
    function check the repo for any yml linting errors
    """
    call_subprocess("markdownlint *.md ")
    print("Stage linting md files -- COMPLETED & PASSED  --")
def check_yml_linting():
    """
    function check the repo for any yml linting errors
    """
    call_subprocess("yamllint -d relaxed .github/workflows/*.yml ")
    print("Stage linting yml -- COMPLETED & PASSED  --")
def check_stylelint():
    """
    function check the repo for any python linting errors on css
    """
    call_subprocess("npx stylelint eaglevision/*.css")
    print("Stage linting CSS (stylelint)- -- COMPLETED & PASSED  --")
def check_spelling():
    """
    check the repo for spelling errors
    """
    call_subprocess("python -m pyspelling")
    print("Stage spell checking -- COMPLETED & PASSED  --")