C++: Add a test for SuccessfullyExtractedFiles.ql and friends.

This commit is contained in:
Geoffrey White
2024-01-19 13:30:23 +00:00
parent 24855ddc64
commit 2eba3db1cb
15 changed files with 56 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
| doesnotcompile.cpp:4:2:4:2 | Recoverable extraction error: identifier 'This' is undefined | Extraction failed in doesnotcompile.cpp with error "doesnotcompile.cpp", line 4: error: identifier "This" is undefined\n \tThis is not correct C/C++ code.\n \t^\n\n | 2 |
| doesnotcompile.cpp:4:10:4:10 | Recoverable extraction error: expected a ';' | Extraction failed in doesnotcompile.cpp with error "doesnotcompile.cpp", line 4: error: expected a ";"\n \tThis is not correct C/C++ code.\n \t ^\n\n | 2 |

View File

@@ -0,0 +1 @@
Diagnostics/Internal/ExtractionErrors.ql

View File

@@ -0,0 +1,2 @@
| doesnotcompile.cpp:4:2:4:2 | Recoverable extraction error: identifier 'This' is undefined | Extraction failed in doesnotcompile.cpp with warning "doesnotcompile.cpp", line 4: error: identifier "This" is undefined\n \tThis is not correct C/C++ code.\n \t^\n\n | 1 |
| doesnotcompile.cpp:4:10:4:10 | Recoverable extraction error: expected a ';' | Extraction failed in doesnotcompile.cpp with warning "doesnotcompile.cpp", line 4: error: expected a ";"\n \tThis is not correct C/C++ code.\n \t ^\n\n | 1 |

View File

@@ -0,0 +1 @@
Diagnostics/ExtractionWarnings.ql

View File

@@ -0,0 +1 @@
Diagnostics/FailedExtractorInvocations.ql

View File

@@ -0,0 +1,6 @@
| containserror.cpp:0:0:0:0 | containserror.cpp | query-tests/Diagnostics/containserror.cpp | fromSource, normalTermination |
| containswarning.cpp:0:0:0:0 | containswarning.cpp | query-tests/Diagnostics/containswarning.cpp | fromSource, normalTermination |
| doesnotcompile.cpp:0:0:0:0 | doesnotcompile.cpp | query-tests/Diagnostics/doesnotcompile.cpp | ExtractionProblem (severity 1), fromSource, normalTermination |
| file://:0:0:0:0 | | | |
| header.h:0:0:0:0 | header.h | query-tests/Diagnostics/header.h | fromSource |
| successful.cpp:0:0:0:0 | successful.cpp | query-tests/Diagnostics/successful.cpp | fromSource, normalTermination |

View File

@@ -0,0 +1,17 @@
import cpp
import Diagnostics.ExtractionProblems
string describe(File f) {
exists(ExtractionProblem e | e.getFile() = f |
result = "ExtractionProblem (severity " + e.getSeverity().toString() + ")"
)
or
f.fromSource() and result = "fromSource"
or
exists(Compilation c | c.getAFileCompiled() = f |
(c.normalTermination() and result = "normalTermination")
)
}
from File f
select f, concat(f.getRelativePath(), ", "), concat(describe(f), ", ")

View File

@@ -0,0 +1,4 @@
| containserror.cpp:0:0:0:0 | containserror.cpp | File successfully extracted. |
| containswarning.cpp:0:0:0:0 | containswarning.cpp | File successfully extracted. |
| header.h:0:0:0:0 | header.h | File successfully extracted. |
| successful.cpp:0:0:0:0 | successful.cpp | File successfully extracted. |

View File

@@ -0,0 +1 @@
Diagnostics/SuccessfullyExtractedFiles.ql

View File

@@ -0,0 +1,5 @@
// semmle-extractor-options: --expect_errors
void containserror() {
#error An error!
}

View File

@@ -0,0 +1,4 @@
void containswarning() {
#warning A warning.
}

View File

@@ -0,0 +1,5 @@
// semmle-extractor-options: --expect_errors
void doesnotcompile() {
This is not correct C/C++ code.
}

View File

@@ -0,0 +1,2 @@
// a header file

View File

@@ -0,0 +1,5 @@
#include "header.h"
void successful() {
}