Exemplo n.º 1
0
    def test_stat_lines_counts_zero_if_directory_does_not_exist(self):
        directory = mkdtemp("-caboose-non-exist-dir-test")
        inner = path.join(directory, 'nonexistant')

        fp = FilePackage()
        fp.add_directory(inner)
        file_iterator = FileIterator([fp])

        stat = StatJavaNcss()
        stat.set_files(file_iterator.files())
        eq_(0, stat.get_stat())
        rmtree(directory)
Exemplo n.º 2
0
    def test_proper_number_of_lines_are_counted_in_single_file(self):
        directory = mkdtemp("-caboose-java-ncss-single-test")
        self._create_file_with_lines(directory, 2, 4, 2)

        fp = FilePackage()
        fp.add_directory(directory)
        file_iterator = FileIterator([fp])

        stat = StatJavaNcss()
        stat.set_files(file_iterator.files())
        eq_(2, stat.get_stat())
        rmtree(directory)
Exemplo n.º 3
0
    def test_proper_number_of_lines_are_counted_in_inner_dir(self):
        directory = mkdtemp("-caboose-numlines-inner-dir-test")
        inner = mkdtemp("-inner-dir", dir=directory)
        self._create_file_with_lines(directory, 2, 3, 4)
        self._create_file_with_lines(inner, 5, 6, 7)

        fp = FilePackage()
        fp.add_directory(directory)
        file_iterator = FileIterator([fp])

        stat = StatJavaNcss()
        stat.set_files(file_iterator.files())
        eq_(7, stat.get_stat())
        rmtree(directory)
Exemplo n.º 4
0
    def test_proper_number_of_lines_in_multiple_dirs(self):
        directory = mkdtemp("-caboose-numlines-multiple-dir-test")
        inner1 = mkdtemp("-inner-dir1", dir=directory)
        inner2 = mkdtemp("-inner-dir2", dir=directory)
        inner3 = mkdtemp("-inner-dir3", dir=directory)
        self._create_file_with_lines(directory, 2, 3, 4)
        self._create_file_with_lines(inner1, 5, 6, 7)
        self._create_file_with_lines(inner2, 8, 9 ,10)
        self._create_file_with_lines(inner3, 13, 14, 15)

        fp = FilePackage()
        fp.add_directories(inner1, inner3)
        file_iterator = FileIterator([fp])

        stat = StatJavaNcss()
        stat.set_files(file_iterator.files())
        eq_(18, stat.get_stat())
        rmtree(directory)
Exemplo n.º 5
0
    def test_stat_lines_works_with_absurd_number_of_files(self):
        directory = mkdtemp("-caboose-absurd-file-count-test")
        self._create_file_with_lines(directory, 5, 6, 7)

        fp = FilePackage()
        fp.add_directory(directory)
        file_iterator = FileIterator([fp])

        files = file_iterator.files()

        #count the same file 5000 times
        files = files * 5000

        stat = StatJavaNcss()
        stat._set_ncss_command("bash -c 'for x in `seq $#`; do echo 5; done' filler")
        stat.set_files(files)
        eq_(25000, stat.get_stat())
        rmtree(directory)
Exemplo n.º 6
0
 def test_stat_has_right_name(self):
     eq_(StatJavaNcss.get_name(), "java_ncss")