Skip to content

Commit fd8f7e0

Browse files
committed
Kotlin: Tweak double_interception test
1 parent fae4a8f commit fd8f7e0

File tree

1 file changed

+13
-3
lines changed
  • java/ql/integration-tests/all-platforms/kotlin/kotlin_double_interception/code

1 file changed

+13
-3
lines changed
Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,41 @@
11
#!/usr/bin/env python3
22

33
import glob
4+
import os
45
import re
56
from create_database_utils import *
67

8+
def say(s):
9+
print(s)
10+
sys.stdout.flush()
11+
12+
say('Doing normal compilation')
713
# This is a normal intercepted compilation
814
runSuccessfully([get_cmd('kotlinc'), 'normal.kt'])
915

16+
say('Identifying extractor jar')
1017
# Find the extractor jar that is being used
1118
trapDir = os.environ['CODEQL_EXTRACTOR_JAVA_TRAP_DIR']
12-
invocationTrapDir = trapDir + '/invocations'
19+
invocationTrapDir = os.path.join(trapDir, 'invocations')
1320
invocationTraps = os.listdir(invocationTrapDir)
1421
if len(invocationTraps) != 1:
1522
raise Exception('Expected to find 1 invocation TRAP, but found ' + str(invocationTraps))
16-
invocationTrap = invocationTrapDir + '/' + invocationTraps[0]
23+
invocationTrap = os.path.join(invocationTrapDir, invocationTraps[0])
1724
with open(invocationTrap, 'r') as f:
1825
content = f.read()
1926
m = re.search('^// Using extractor: (.*)$', content, flags = re.MULTILINE)
2027
extractorJar = m.group(1)
2128

2229
def getManualFlags(invocationTrapName):
23-
return ['-Xplugin=' + extractorJar, '-P', 'plugin:kotlin-extractor:invocationTrapFile=' + trapDir + '/invocations/' + invocationTrapName + '.trap']
30+
return ['-Xplugin=' + extractorJar, '-P', 'plugin:kotlin-extractor:invocationTrapFile=' + os.path.join(trapDir, 'invocations', invocationTrapName + '.trap')]
2431

2532
# This is both normally intercepted, and it has the extractor flags manually added
33+
say('Doing double-interception compilation')
2634
runSuccessfully([get_cmd('kotlinc'), 'doubleIntercepted.kt'] + getManualFlags('doubleIntercepted'))
2735
os.environ['CODEQL_EXTRACTOR_JAVA_AGENT_DISABLE_KOTLIN'] = 'true'
2836
# We don't see this compilation at all
37+
say('Doing unseen compilation')
2938
runSuccessfully([get_cmd('kotlinc'), 'notSeen.kt'])
3039
# This is extracted as it has the extractor flags manually added
40+
say('Doing manual compilation')
3141
runSuccessfully([get_cmd('kotlinc'), 'manual.kt'] + getManualFlags('manual'))

0 commit comments

Comments
 (0)