Kotlin: Add a test for path transformers

This commit is contained in:
Ian Lynagh
2024-01-30 17:40:43 +00:00
parent 79d9109850
commit 2eb9b61412
4 changed files with 22 additions and 0 deletions

View File

@@ -0,0 +1 @@
| file:///src/kotlin_source.kt:1:1:2:1 | Foo |

View File

@@ -0,0 +1,5 @@
import java
from Class c
where c.fromSource()
select c

View File

@@ -0,0 +1,2 @@
class Foo {
}

View File

@@ -0,0 +1,14 @@
from create_database_utils import *
path_transformer_file = 'path_transformer'
root = os.getcwd().replace('\\', '/')
with open(path_transformer_file, 'w') as f:
f.write('#/src\n' + root + '//\n')
os.environ['SEMMLE_PATH_TRANSFORMER'] = root + '/' + path_transformer_file
run_codeql_database_create(["kotlinc kotlin_source.kt"], lang="java")
files = ['test-db/trap/java/src/kotlin_source.kt.trap.gz', 'test-db/src/src/kotlin_source.kt']
exists = list(map(os.path.exists, files))
if exists != [True] * 2:
print(exists)
raise Exception("Didn't get expected filed")