Skip to content

Commit 1736117

Browse files
committed
fix bug;增加回归测试一枚
1 parent 5573323 commit 1736117

File tree

11 files changed

+71
-14
lines changed

11 files changed

+71
-14
lines changed

src/scan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void scan(fs::path src_path)
1919

2020
string line;
2121
regex usingcpp_pat{ R"(^\s*#include\s+"([\w\./]+)\.h"\s+//\s+usingcpp)" };
22-
regex using_pat{ R"(using\s+([\w\./]+\.(c|cpp|cxx|c\+\+|C|cc|cp|CPP)))" };
22+
regex using_pat{ R"(using\s+([\w\./]+\.(cpp|cxx|c\+\+|cc|c)))" }; // | 或的顺序还挺重要,把长的排前边。免得前缀就匹配。
2323
regex linklib_pat{ R"(//\s+linklib\s+([\w\-\.]+))" };
2424
string compiler_specific_linklib_string = R"(//\s+)" + cc_info[cc].compiler_name;
2525
compiler_specific_linklib_string += R"(-linklib\s+([\w\-\.]+))";

test/helloworld/main.cpp

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <vector>
33
#include <string>
44

5-
#include "foo.h" // using foo.cpp
5+
#include "foo.h" // using foo.cpp
66
#include "bar.h" // using bar.cpp
77

88
using namespace std;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "bar.h"
2+
3+
int bar()
4+
{
5+
return 3;
6+
}

test/using-a-cpp-many-times/bar.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#ifndef BAR_H
2+
#define BAR_H
3+
4+
int bar();
5+
6+
7+
#endif // BAR_H
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <iostream>
2+
#include "foo.h"
3+
#include "bar.h" // using bar.cpp
4+
5+
using namespace std;
6+
7+
void foo()
8+
{
9+
bar();
10+
}

test/using-a-cpp-many-times/foo.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef FOO_H
2+
#define FOO_H
3+
4+
void foo();
5+
6+
7+
8+
#endif // FOO_H
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <iostream>
2+
#include <vector>
3+
#include <string>
4+
5+
#include "foo.h" // using foo.cpp
6+
#include "bar.h" // using bar.cpp
7+
8+
using namespace std;
9+
10+
int main()
11+
{
12+
foo();
13+
bar();
14+
15+
return 0;
16+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
cpps --clear -c gcc -v main.cpp
4+
# CHECK: compiling main.cpp
5+
# CHECK-NEXT: compiling foo.cpp
6+
# CHECK-NEXT: compiling bar.cpp
7+
# CHECK-NEXT: linking main.cpp.gcc.exe
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@ECHO OFF
2+
3+
cpps --clear -c mingw -v main.cpp
4+
rem CHECK: compiling main.cpp
5+
rem CHECK-NEXT: compiling foo.cpp
6+
rem CHECK-NEXT: compiling bar.cpp
7+
rem CHECK-NEXT: linking main.cpp.mingw.exe

0 commit comments

Comments
 (0)