This commit is contained in:
calum 2018-10-08 17:26:30 +01:00
Родитель abe5d0dd72
Коммит 2fdf766750
3 изменённых файлов: 18 добавлений и 23 удалений

Просмотреть файл

@ -17,14 +17,10 @@ class UsedInSource extends GeneratedDeclaration {
or
this = any(Call c).getTarget()
or
exists(ValueOrRefType t | t.fromSource() | this = t.getABaseType())
or
exists(Variable v | v.fromSource() | this = v.getType())
this = any(TypeMention tm).getType()
or
exists(Virtualizable v | v.fromSource() | this = v.getImplementee() or this = v.getOverridee())
or
this = any(Attribute a).getType()
or
this = any(Attribute a).getType().getAConstructor()
)
and

Просмотреть файл

@ -239,7 +239,7 @@ private class GeneratedNamespace extends Namespace, GeneratedElement {
final string getStubs() {
result = getPreamble() +
getTypeStubs() +
getSubNamespaces(0) +
getSubNamespaces() +
getPostAmble()
}
@ -254,10 +254,9 @@ private class GeneratedNamespace extends Namespace, GeneratedElement {
result = count(GeneratedNamespace g | g.getParentNamespace() = this)
}
private string getSubNamespaces(int n) {
result = getChildNamespace(n).getStubs() + getSubNamespaces(n+1)
or
n = getChildNamespaceCount() and result = ""
language[monotonicAggregates]
private string getSubNamespaces() {
result = concat(int i | exists(getChildNamespace(i)) | getChildNamespace(i).getStubs())
}
private string getTypeStubs() {

Просмотреть файл

@ -10,6 +10,7 @@
import sys
import os
import subprocess
print('Script to generate stub.cs files for C# qltest projects')
@ -42,9 +43,9 @@ if not foundCS:
print("Test directory does not contain .cs files. Please specify a working qltest directory.")
exit(1)
cmd = 'odasa selfTest'
print(cmd)
if os.system(cmd):
cmd = ['odasa', 'selfTest']
print('Running ' + ' '.join(cmd))
if subprocess.check_call(cmd):
print("odasa selfTest failed. Ensure odasa is on your current path.")
exit(1)
@ -57,9 +58,9 @@ if os.path.isfile(outputFile):
os.remove(outputFile) # It would interfere with the test.
print("Removed previous", outputFile)
cmd = 'odasa qltest --optimize --leave-temp-files "' + testDir + '"'
print(cmd)
if os.system(cmd) != 0:
cmd = ['odasa', 'qltest', '--optimize', '--leave-temp-files', testDir]
print('Running ' + ' '.join(cmd))
if subprocess.check_call(cmd):
print("qltest failed. Please fix up the test before proceeding.")
exit(1)
@ -69,9 +70,9 @@ if not os.path.isdir(dbDir):
print("Expected database directory " + dbDir + " not found. Please contact Semmle.")
exit(1)
cmd = 'odasa runQuery --query "' + os.path.join(csharpQueries, 'MinimalStubsFromSource.ql') + '" --db "' + dbDir +'" --output-file "' + outputFile + '"'
print(cmd)
if os.system(cmd):
cmd = ['odasa', 'runQuery', '--query', os.path.join(csharpQueries, 'MinimalStubsFromSource.ql'), '--db', dbDir, '--output-file', outputFile]
print('Running ' + ' '.join(cmd))
if subprocess.check_call(cmd):
print('Failed to run the query to generate output file. Please contact Semmle.')
exit(1)
@ -93,10 +94,9 @@ f = open(outputFile, "wb")
f.write(contents)
f.close()
cmd = 'odasa qltest --optimize "' + testDir + '"'
print(cmd)
if os.system(cmd):
cmd = ['odasa', 'qltest', '--optimize', testDir]
print('Running ' + ' '.join(cmd))
if subprocess.check_call(cmd):
print('\nTest failed. You may need to fix up', outputFile)
print('It may help to view', outputFile, ' in Visual Studio')
print("Next steps:")