@@ -22,33 +22,31 @@ namespace {
2222
2323class SpecialCaseListTest : public ::testing::Test {
2424protected:
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 ) {
2827 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 ();
3130 std::unique_ptr<MemoryBuffer> MB = MemoryBuffer::getMemBuffer (S);
3231 return SpecialCaseList::create (MB.get (), Error);
3332 }
3433
3534 std::unique_ptr<SpecialCaseList> makeSpecialCaseList (StringRef List,
36- bool UseGlobs = true ) {
35+ int Version = 0 ) {
3736 std::string Error;
38- auto SCL = makeSpecialCaseList (List, Error, UseGlobs );
37+ auto SCL = makeSpecialCaseList (List, Error, Version );
3938 assert (SCL);
4039 assert (Error == " " );
4140 return SCL;
4241 }
4342
44- std::string makeSpecialCaseListFile (StringRef Contents,
45- bool UseGlobs = true ) {
43+ std::string makeSpecialCaseListFile (StringRef Contents, int Version = 0 ) {
4644 int FD;
4745 SmallString<64 > Path;
4846 sys::fs::createTemporaryFile (" SpecialCaseListTest" , " temp" , FD, Path);
4947 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 " ;
5250 OF << Contents;
5351 OF.close ();
5452 return std::string (Path.str ());
@@ -261,7 +259,7 @@ TEST_F(SpecialCaseListTest, Version1) {
261259 " fun:foo.*\n "
262260 " fun:abc|def\n "
263261 " fun:b.r\n " ,
264- /* UseGlobs =*/ false );
262+ /* Version =*/ 1 );
265263
266264 EXPECT_TRUE (SCL->inSection (" sect1" , " fun" , " fooz" ));
267265 EXPECT_TRUE (SCL->inSection (" sect2" , " fun" , " fooz" ));
@@ -309,6 +307,46 @@ TEST_F(SpecialCaseListTest, Version2) {
309307 EXPECT_FALSE (SCL->inSection (" sect3" , " fun" , " bar" ));
310308}
311309
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+
312350TEST_F (SpecialCaseListTest, LinesInSection) {
313351 std::unique_ptr<SpecialCaseList> SCL = makeSpecialCaseList (" fun:foo\n "
314352 " fun:bar\n "
0 commit comments