Skip to content

Commit feddc39

Browse files
committed
Add test for folder skip recognition
1 parent 529357d commit feddc39

File tree

4 files changed

+82
-0
lines changed

4 files changed

+82
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
OBJS = $(SRCS:.cpp=.o)
2+
3+
CXXFLAGS = -Wno-all -Wno-extra -Wno-division-by-zero
4+
5+
SRCS = skipme/skipme.cpp
6+
7+
.cpp.o:
8+
$(CXX) $(CXXFLAGS) -c $< -o $@
9+
10+
all: $(OBJS)
11+
12+
clean:
13+
rm -rf *.o
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-*skipme
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// -------------------------------------------------------------------------
2+
// Part of the CodeChecker project, under the Apache License v2.0 with
3+
// LLVM Exceptions. See LICENSE for license information.
4+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5+
// -------------------------------------------------------------------------
6+
7+
// This file is to be included in a skip list file.
8+
9+
void skipped_test(int z) {
10+
if (z == 0)
11+
int x = 1 / z; // warn
12+
}

analyzer/tests/functional/skip/test_skip.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,62 @@ def test_skip(self):
171171
"Reports from headers should be kept"
172172
" if the header is not on the skiplist")
173173

174+
def test_skip_directory(self):
175+
"""Test wether directories in skipfile entries works correctly"""
176+
with tempfile.NamedTemporaryFile(
177+
mode='w',
178+
suffix="skipfile",
179+
encoding='utf-8') as skip_file:
180+
181+
# Skip the `skipme` folder, the way its in the documentation
182+
skip_file.write('\n'.join([
183+
'-*skipme/*',
184+
]))
185+
skip_file.flush()
186+
self.__log_and_analyze("skip_folder", ["--ignore", skip_file.name])
187+
188+
# Check if the folder is skipped
189+
# There shouldn't be any report generated
190+
report_dir_files = os.listdir(self.report_dir)
191+
for f in report_dir_files:
192+
self.assertFalse("skipme.cpp" in f)
193+
194+
with tempfile.NamedTemporaryFile(
195+
mode='w',
196+
suffix="skipfile",
197+
encoding='utf-8') as skip_file:
198+
199+
# Skip the `skipme` folder, leaving out the '*'
200+
skip_file.write('\n'.join([
201+
'-*skipme/',
202+
]))
203+
skip_file.flush()
204+
self.__log_and_analyze("skip_folder", ["--ignore", skip_file.name])
205+
206+
# Check if the folder is skipped
207+
# There shouldn't be any report generated
208+
report_dir_files = os.listdir(self.report_dir)
209+
for f in report_dir_files:
210+
self.assertFalse("skipme.cpp" in f)
211+
212+
with tempfile.NamedTemporaryFile(
213+
mode='w',
214+
suffix="skipfile",
215+
encoding='utf-8') as skip_file:
216+
217+
# Skip the `skipme` folder, without any indication that its a folder
218+
skip_file.write('\n'.join([
219+
'-*skipme',
220+
]))
221+
skip_file.flush()
222+
self.__log_and_analyze("skip_folder", ["--ignore", skip_file.name])
223+
224+
# Check if the folder is skipped
225+
# There shouldn't be any report generated
226+
report_dir_files = os.listdir(self.report_dir)
227+
for f in report_dir_files:
228+
self.assertFalse("skipme.cpp" in f)
229+
174230
def test_drop_reports(self):
175231
"""Analyze a project with a skip file."""
176232
# we should not see a report from skip.h

0 commit comments

Comments
 (0)