From 7bc68c430265a901533403a209e2ecbceda98c80 Mon Sep 17 00:00:00 2001 From: Henning Makholm Date: Fri, 6 Dec 2019 18:24:37 +0100 Subject: [PATCH] Adapt Go tests to `codeql test` These changes make the tests work with the coming `codeql test` support. The `queries.xml` file defines which extractor the `codeql test` runner will use to extract databases for the tests. In the future one will be able to write this information in `qlpack.yml`, but we can't do that immediately because the _existing_ CodeQL tooling would refuse to parse a `qlpack.yml` that has the new field in it. --- codeql-extractor.yml | 1 + codeql-tools/index.cmd | 7 +++++++ codeql-tools/index.sh | 10 ++++++++++ ql/test/queries.xml | 1 + 4 files changed, 19 insertions(+) create mode 100644 codeql-tools/index.cmd create mode 100755 codeql-tools/index.sh create mode 100644 ql/test/queries.xml diff --git a/codeql-extractor.yml b/codeql-extractor.yml index 3e98f064425..3c81755de5c 100644 --- a/codeql-extractor.yml +++ b/codeql-extractor.yml @@ -14,3 +14,4 @@ file_types: display_name: Go extensions: - .go +legacy_qltest_extraction: true diff --git a/codeql-tools/index.cmd b/codeql-tools/index.cmd new file mode 100644 index 00000000000..15d7548c1d9 --- /dev/null +++ b/codeql-tools/index.cmd @@ -0,0 +1,7 @@ +@echo off +SETLOCAL EnableDelayedExpansion + +type NUL && "%CODEQL_EXTRACTOR_GO_ROOT%/tools/%CODEQL_PLATFORM%/go-extractor.exe" -mod=vendor ./... +exit /b %ERRORLEVEL% + +ENDLOCAL diff --git a/codeql-tools/index.sh b/codeql-tools/index.sh new file mode 100755 index 00000000000..655fb5eeca3 --- /dev/null +++ b/codeql-tools/index.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +set -eu + +if [ "$CODEQL_PLATFORM" != "linux64" ] && [ "$CODEQL_PLATFORM" != "osx64" ] ; then + echo "Automatic build detection for $CODEQL_PLATFORM is not implemented." + exit 1 +fi + +"$CODEQL_EXTRACTOR_GO_ROOT/tools/$CODEQL_PLATFORM/go-extractor" -mod=vendor ./... diff --git a/ql/test/queries.xml b/ql/test/queries.xml new file mode 100644 index 00000000000..6a456b21d09 --- /dev/null +++ b/ql/test/queries.xml @@ -0,0 +1 @@ +