@@ -22,33 +22,31 @@ namespace {
22
22
23
23
class SpecialCaseListTest : public ::testing::Test {
24
24
protected:
25
- std::unique_ptr<SpecialCaseList> makeSpecialCaseList (StringRef List,
26
- std::string &Error,
27
- bool UseGlobs = true ) {
25
+ std::unique_ptr<SpecialCaseList>
26
+ makeSpecialCaseList (StringRef List, std::string &Error, int Version = 0 ) {
28
27
auto S = List.str ();
29
- if (!UseGlobs )
30
- S = (Twine (" #!special-case-list-v1 \n " ) + S).str ();
28
+ if (Version )
29
+ S = (Twine (" #!special-case-list-v " ) + Twine (Version) + " \n " + S).str ();
31
30
std::unique_ptr<MemoryBuffer> MB = MemoryBuffer::getMemBuffer (S);
32
31
return SpecialCaseList::create (MB.get (), Error);
33
32
}
34
33
35
34
std::unique_ptr<SpecialCaseList> makeSpecialCaseList (StringRef List,
36
- bool UseGlobs = true ) {
35
+ int Version = 0 ) {
37
36
std::string Error;
38
- auto SCL = makeSpecialCaseList (List, Error, UseGlobs );
37
+ auto SCL = makeSpecialCaseList (List, Error, Version );
39
38
assert (SCL);
40
39
assert (Error == " " );
41
40
return SCL;
42
41
}
43
42
44
- std::string makeSpecialCaseListFile (StringRef Contents,
45
- bool UseGlobs = true ) {
43
+ std::string makeSpecialCaseListFile (StringRef Contents, int Version = 0 ) {
46
44
int FD;
47
45
SmallString<64 > Path;
48
46
sys::fs::createTemporaryFile (" SpecialCaseListTest" , " temp" , FD, Path);
49
47
raw_fd_ostream OF (FD, true , true );
50
- if (!UseGlobs )
51
- OF << " #!special-case-list-v1 \n " ;
48
+ if (Version )
49
+ OF << " #!special-case-list-v " << Version << " \n " ;
52
50
OF << Contents;
53
51
OF.close ();
54
52
return std::string (Path.str ());
@@ -261,7 +259,7 @@ TEST_F(SpecialCaseListTest, Version1) {
261
259
" fun:foo.*\n "
262
260
" fun:abc|def\n "
263
261
" fun:b.r\n " ,
264
- /* UseGlobs =*/ false );
262
+ /* Version =*/ 1 );
265
263
266
264
EXPECT_TRUE (SCL->inSection (" sect1" , " fun" , " fooz" ));
267
265
EXPECT_TRUE (SCL->inSection (" sect2" , " fun" , " fooz" ));
@@ -309,6 +307,46 @@ TEST_F(SpecialCaseListTest, Version2) {
309
307
EXPECT_FALSE (SCL->inSection (" sect3" , " fun" , " bar" ));
310
308
}
311
309
310
+ TEST_F (SpecialCaseListTest, DotSlash) {
311
+ std::unique_ptr<SpecialCaseList> SCL2 = makeSpecialCaseList (" [dot]\n "
312
+ " fun:./foo\n "
313
+ " src:./bar\n "
314
+ " [not]\n "
315
+ " fun:foo\n "
316
+ " src:bar\n " );
317
+ std::unique_ptr<SpecialCaseList> SCL3 = makeSpecialCaseList (" [dot]\n "
318
+ " fun:./foo\n "
319
+ " src:./bar\n "
320
+ " [not]\n "
321
+ " fun:foo\n "
322
+ " src:bar\n " ,
323
+ /* Version=*/ 3 );
324
+
325
+ EXPECT_TRUE (SCL2->inSection (" dot" , " fun" , " ./foo" ));
326
+ EXPECT_TRUE (SCL3->inSection (" dot" , " fun" , " ./foo" ));
327
+
328
+ EXPECT_FALSE (SCL2->inSection (" dot" , " fun" , " foo" ));
329
+ EXPECT_FALSE (SCL3->inSection (" dot" , " fun" , " foo" ));
330
+
331
+ EXPECT_TRUE (SCL2->inSection (" dot" , " src" , " ./bar" ));
332
+ EXPECT_FALSE (SCL3->inSection (" dot" , " src" , " ./bar" ));
333
+
334
+ EXPECT_FALSE (SCL2->inSection (" dot" , " src" , " bar" ));
335
+ EXPECT_FALSE (SCL3->inSection (" dot" , " src" , " bar" ));
336
+
337
+ EXPECT_FALSE (SCL2->inSection (" not" , " fun" , " ./foo" ));
338
+ EXPECT_FALSE (SCL3->inSection (" not" , " fun" , " ./foo" ));
339
+
340
+ EXPECT_TRUE (SCL2->inSection (" not" , " fun" , " foo" ));
341
+ EXPECT_TRUE (SCL3->inSection (" not" , " fun" , " foo" ));
342
+
343
+ EXPECT_FALSE (SCL2->inSection (" not" , " src" , " ./bar" ));
344
+ EXPECT_TRUE (SCL3->inSection (" not" , " src" , " ./bar" ));
345
+
346
+ EXPECT_TRUE (SCL2->inSection (" not" , " src" , " bar" ));
347
+ EXPECT_TRUE (SCL3->inSection (" not" , " src" , " bar" ));
348
+ }
349
+
312
350
TEST_F (SpecialCaseListTest, LinesInSection) {
313
351
std::unique_ptr<SpecialCaseList> SCL = makeSpecialCaseList (" fun:foo\n "
314
352
" fun:bar\n "
0 commit comments