Skip to content

Commit

Permalink
fix bug;增加回归测试一枚
Browse files Browse the repository at this point in the history
  • Loading branch information
duyanning committed Jul 22, 2019
1 parent 5573323 commit 1736117
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void scan(fs::path src_path)

string line;
regex usingcpp_pat{ R"(^\s*#include\s+"([\w\./]+)\.h"\s+//\s+usingcpp)" };
regex using_pat{ R"(using\s+([\w\./]+\.(c|cpp|cxx|c\+\+|C|cc|cp|CPP)))" };
regex using_pat{ R"(using\s+([\w\./]+\.(cpp|cxx|c\+\+|cc|c)))" }; // | 或的顺序还挺重要,把长的排前边。免得前缀就匹配。
regex linklib_pat{ R"(//\s+linklib\s+([\w\-\.]+))" };
string compiler_specific_linklib_string = R"(//\s+)" + cc_info[cc].compiler_name;
compiler_specific_linklib_string += R"(-linklib\s+([\w\-\.]+))";
Expand Down
12 changes: 0 additions & 12 deletions test/helloworld/main.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion test/multiple-srcs/hello.cpp → test/multiple-srcs/main.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <vector>
#include <string>

#include "foo.h" // using foo.cpp
#include "foo.h" // using foo.cpp
#include "bar.h" // using bar.cpp

using namespace std;
Expand Down
6 changes: 6 additions & 0 deletions test/using-a-cpp-many-times/bar.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "bar.h"

int bar()
{
return 3;
}
7 changes: 7 additions & 0 deletions test/using-a-cpp-many-times/bar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef BAR_H
#define BAR_H

int bar();


#endif // BAR_H
10 changes: 10 additions & 0 deletions test/using-a-cpp-many-times/foo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <iostream>
#include "foo.h"
#include "bar.h" // using bar.cpp

using namespace std;

void foo()
{
bar();
}
8 changes: 8 additions & 0 deletions test/using-a-cpp-many-times/foo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef FOO_H
#define FOO_H

void foo();



#endif // FOO_H
16 changes: 16 additions & 0 deletions test/using-a-cpp-many-times/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <iostream>
#include <vector>
#include <string>

#include "foo.h" // using foo.cpp
#include "bar.h" // using bar.cpp

using namespace std;

int main()
{
foo();
bar();

return 0;
}
7 changes: 7 additions & 0 deletions test/using-a-cpp-many-times/run-gcc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

cpps --clear -c gcc -v main.cpp
# CHECK: compiling main.cpp
# CHECK-NEXT: compiling foo.cpp
# CHECK-NEXT: compiling bar.cpp
# CHECK-NEXT: linking main.cpp.gcc.exe
7 changes: 7 additions & 0 deletions test/using-a-cpp-many-times/run-mingw.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@ECHO OFF

cpps --clear -c mingw -v main.cpp
rem CHECK: compiling main.cpp
rem CHECK-NEXT: compiling foo.cpp
rem CHECK-NEXT: compiling bar.cpp
rem CHECK-NEXT: linking main.cpp.mingw.exe
8 changes: 8 additions & 0 deletions test/using-a-cpp-many-times/run-vc.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@ECHO OFF

cpps --clear -c vc -v main.cpp
rem CHECK: compiling main.cpp
rem CHECK-NEXT: compiling foo.cpp
rem CHECK-NEXT: compiling bar.cpp
rem CHECK-NEXT: linking main.cpp.vc.exe

0 comments on commit 1736117

Please sign in to comment.