Exemple #1
0
def run(project_id, repo_path, cursor, **options):
    query = 'SELECT language FROM projects WHERE id = %d' % project_id
    cursor.execute(query)

    record = cursor.fetchone()
    discoverer = get_test_discoverer(language=record[0])
    proportion = discoverer.discover(repo_path)

    threshold = options['threshold']

    return (proportion >= threshold), proportion
Exemple #2
0
def run(project_id, repo_path, cursor, **options):
    query = 'SELECT language FROM projects WHERE id = %d' % project_id
    cursor.execute(query)

    record = cursor.fetchone()
    discoverer = get_test_discoverer(language=record[0])
    proportion = discoverer.discover(repo_path)

    threshold = options['threshold']

    return (proportion >= threshold), proportion
Exemple #3
0
def run(project_id, repo_path, cursor, **options):
    print("----- METRIC: UNIT TEST -----")
    fp = open('l' + str(project_id), 'r')
    for x in fp:
        lang = x.replace("\n", "")
        break
    repo_path_abs = str(os.getcwd()) + "/" + repo_path
    discoverer = get_test_discoverer(language=lang)
    proportion = discoverer.discover(repo_path_abs)
    threshold = options['threshold']
    print('proportion: ', proportion)
    return (proportion >= threshold), proportion
Exemple #4
0
def unit_test():
    proportion = 0.0
    lang = ""
    for x in range(3,arg_len-1):
        lang += str(sys.argv[x])
    flag1 = False
    if(lang == 'NULL'):
        for token in git_tokens:
            if(flag1 == True):
                break
            else:
                try:
                    lang = requests.get(URL, auth = HTTPBasicAuth(git_tokens[token], token)).json()['language']
                    flag1 = True
                    break
                except:
                    continue
        if(flag1 == False):
            try:
                lang = requests.get(URL).json()['language']
                print('without token - language - fetch ok')
            except Exception as ex:
                print(ex)
    os.chdir(root_directory)
    repo_path_abs = str(os.getcwd()) + "/" +repo_path
    try:
        try:
            discoverer = get_test_discoverer(language=lang)
            proportion = discoverer.discover(repo_path_abs)
        except Exception as ex:
            print(ex)
            print('Failed to get Unit Test Value...')
            proportion = 0.0
        if(proportion > 0.0):
            val = (str(proportion),repo_id)
            QUERY = '''UPDATE `repoquester_results` SET `unit_test`=? WHERE `repo_id`=?'''
            try:
                os.chdir(root_directory)
                conn = sqlite3.connect('repo_quester.db',timeout=180)
                conn.execute(QUERY,val)
                conn.commit()
                conn.close()
                print('UNIT_TEST: ',proportion,' ok')
            except Exception as ex:
                print(ex)
                os.chdir(root_directory)
                conn = sqlite3.connect('repo_quester.db',timeout=180)
                conn.execute(QUERY,val)
                conn.commit()
                conn.close()
                print('UNIT_TEST: ',proportion,' trying again.. ok')
    except Exception as ex:
        print(ex)
def run(project_id, repo_path, cursor, **options):
    print("----- METRIC: UNIT TEST -----")
    query = 'SELECT language FROM projects WHERE id = %d' % project_id
    cursor.execute(query)
    if (platform.system() == 'Windows'):
        repo_path_abs = str(os.getcwd()) + "\\" + repo_path
    else:
        repo_path_abs = str(os.getcwd()) + "/" + repo_path
    record = cursor.fetchone()
    discoverer = get_test_discoverer(language=record[0])
    proportion = discoverer.discover(repo_path_abs)
    threshold = options['threshold']
    print('Unit Test: ', proportion)
    return (proportion >= threshold), proportion
Exemple #6
0
def run(project_id, repo_path, cursor, **options):
    print("----- METRIC: UNIT TEST -----")
    query = 'SELECT language FROM projects WHERE id = %d' % project_id
    cursor.execute(query)
    # print('current_unit_test_directory: ',os.getcwd())
    repo_path_abs = str(os.getcwd()) + "\\" + repo_path
    #print('repo_path_unit_test: ',repo_path_abs)
    record = cursor.fetchone()
    # print('lan_unit_test: ',record[0])
    discoverer = get_test_discoverer(language=record[0])
    # print('discoverer_unit_test: ',discoverer)
    proportion = discoverer.discover(repo_path_abs)

    threshold = options['threshold']
    print('proportion: ', proportion)
    return (proportion >= threshold), proportion
Exemple #7
0
    def test_get_test_discoverer(self):
        # Test: Available test discoverers
        self.assertIsInstance(get_test_discoverer('C'), c.CTestDiscoverer)
        self.assertIsInstance(get_test_discoverer('C'), TestDiscoverer)

        self.assertIsInstance(get_test_discoverer('C++'),
                              cpp.CppTestDiscoverer)
        self.assertIsInstance(get_test_discoverer('C++'), TestDiscoverer)

        self.assertIsInstance(get_test_discoverer('C#'),
                              csharp.CSharpTestDiscoverer)
        self.assertIsInstance(get_test_discoverer('C#'), TestDiscoverer)

        self.assertIsInstance(get_test_discoverer('Java'),
                              java.JavaTestDiscoverer)
        self.assertIsInstance(get_test_discoverer('Java'), TestDiscoverer)

        self.assertIsInstance(get_test_discoverer('JavaScript'),
                              javascript.JavaScriptTestDiscoverer)
        self.assertIsInstance(get_test_discoverer('JavaScript'),
                              TestDiscoverer)

        self.assertIsInstance(get_test_discoverer('Objective-C'),
                              objectivec.ObjectiveCTestDiscoverer)
        self.assertIsInstance(get_test_discoverer('Objective-C'),
                              TestDiscoverer)

        self.assertIsInstance(get_test_discoverer('PHP'),
                              php.PhpTestDiscoverer)
        self.assertIsInstance(get_test_discoverer('PHP'), TestDiscoverer)

        self.assertIsInstance(get_test_discoverer('Python'),
                              python.PythonTestDiscoverer)
        self.assertIsInstance(get_test_discoverer('Python'), TestDiscoverer)

        self.assertIsInstance(get_test_discoverer('Ruby'),
                              ruby.RubyTestDiscoverer)
        self.assertIsInstance(get_test_discoverer('Ruby'), TestDiscoverer)

        # Test: Test discoverer cached objects
        self.assertEqual(id(get_test_discoverer('Ruby')),
                         id(get_test_discoverer('Ruby')))

        # Test: Case insensitivity of language
        self.assertIsInstance(get_test_discoverer('pYtHoN'),
                              python.PythonTestDiscoverer)

        # Test: Unavailable test discoverer
        self.assertRaises(Exception, get_test_discoverer, 'Haskell')
 def setUp(self):
     self.discoverer = get_test_discoverer('Java')
Exemple #9
0
 def setUp(self):
     self.discoverer = get_test_discoverer('C++')
Exemple #10
0
 def setUp(self):
     self.discoverer = get_test_discoverer('Objective-C')
Exemple #11
0
                        _, a_score = architecture_main.run(None, p_file_name, fake_cursor, threshold=0)
                        results.append(a_score)
                    elif feature == 'management':
                        m_score = get_management_score(p_issues, earliest_time, latest_time)
                        results.append(m_score)
                    elif feature == 'community':
                        c_score = get_contributor_score(p_commits)
                        results.append(c_score)
                    elif feature == 'continuous_integration':
                        _, ci_score = ci_main.run(None, p_file_name, None)
                        results.append(ci_score)
                    elif feature == 'documentation':
                        _, d_score = documentation_main.run(None, p_file_name, fake_cursor, threshold=0)
                        results.append(d_score)
                    elif feature == 'history':
                        h_score = get_history_score(p_commits, earliest_time, latest_time)
                        results.append(h_score)
                    elif feature == 'license':
                        l_score = int(licenses.loc[project, 'license'])
                        results.append(l_score)
                    elif feature == 'unit_test':
                        u_score = get_test_discoverer(languages[index]).discover(p_file_name)
                        results.append(u_score)
                if delete_after:
                    shutil.rmtree(p_file_name)  # delete analysed repository if declared in config
                to_write = project
                to_write.extend(results)
                writer.writerow(to_write)  # write results to file
    except IOError as err:
        print(err)
Exemple #12
0
 def setUp(self):
     self.discoverer = get_test_discoverer("Ruby")
Exemple #13
0
    def test_get_test_discoverer(self):
        # Test: Available test discoverers
        self.assertIsInstance(
            get_test_discoverer('C'),
            c.CTestDiscoverer
        )
        self.assertIsInstance(
            get_test_discoverer('C'),
            TestDiscoverer
        )

        self.assertIsInstance(
            get_test_discoverer('C++'),
            cpp.CppTestDiscoverer
        )
        self.assertIsInstance(
            get_test_discoverer('C++'),
            TestDiscoverer
        )

        self.assertIsInstance(
            get_test_discoverer('C#'),
            csharp.CSharpTestDiscoverer
        )
        self.assertIsInstance(
            get_test_discoverer('C#'),
            TestDiscoverer
        )

        self.assertIsInstance(
            get_test_discoverer('Java'),
            java.JavaTestDiscoverer
        )
        self.assertIsInstance(
            get_test_discoverer('Java'),
            TestDiscoverer
        )

        self.assertIsInstance(
            get_test_discoverer('JavaScript'),
            javascript.JavaScriptTestDiscoverer
        )
        self.assertIsInstance(
            get_test_discoverer('JavaScript'),
            TestDiscoverer
        )

        self.assertIsInstance(
            get_test_discoverer('Objective-C'),
            objectivec.ObjectiveCTestDiscoverer
        )
        self.assertIsInstance(
            get_test_discoverer('Objective-C'),
            TestDiscoverer
        )

        self.assertIsInstance(
            get_test_discoverer('PHP'),
            php.PhpTestDiscoverer
        )
        self.assertIsInstance(
            get_test_discoverer('PHP'),
            TestDiscoverer
        )

        self.assertIsInstance(
            get_test_discoverer('Python'),
            python.PythonTestDiscoverer
        )
        self.assertIsInstance(
            get_test_discoverer('Python'),
            TestDiscoverer
        )

        self.assertIsInstance(
            get_test_discoverer('Ruby'),
            ruby.RubyTestDiscoverer
        )
        self.assertIsInstance(
            get_test_discoverer('Ruby'),
            TestDiscoverer
        )

        # Test: Test discoverer cached objects
        self.assertEqual(
            id(get_test_discoverer('Ruby')),
            id(get_test_discoverer('Ruby'))
        )

        # Test: Case insensitivity of language
        self.assertIsInstance(
            get_test_discoverer('pYtHoN'),
            python.PythonTestDiscoverer
        )

        # Test: Unavailable test discoverer
        self.assertRaises(
            Exception, get_test_discoverer, 'Haskell'
        )
Exemple #14
0
 def setUp(self):
     self.discoverer = get_test_discoverer('Objective-C')
Exemple #15
0
 def setUp(self):
     self.discoverer = get_test_discoverer('Python')
Exemple #16
0
 def setUp(self):
     self.discoverer = get_test_discoverer('Python')
Exemple #17
0
 def setUp(self):
     self.discoverer = get_test_discoverer('Ruby')
Exemple #18
0
 def setUp(self):
     self.discoverer = get_test_discoverer('C++')