Rust: fix qltest on macOS, and add CI cross-platform testing of it

This commit is contained in:
Paolo Tranquilli
2024-10-25 12:15:15 +02:00
parent 0b538313fb
commit 4e8b6dc038
14 changed files with 48 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
fn foo() {
wat
is
this?
}

View File

@@ -0,0 +1,5 @@
import rust
from Function f
where exists(f.getLocation().getFile().getRelativePath())
select f

View File

@@ -0,0 +1 @@
qltest_cargo_check: true

View File

@@ -0,0 +1 @@
| test.rs:1:1:1:11 | foo |

View File

@@ -0,0 +1,5 @@
import rust
from Function f
where exists(f.getLocation().getFile().getRelativePath())
select f

View File

@@ -0,0 +1 @@
fn foo() {}

View File

@@ -0,0 +1,2 @@
| main.rs:1:1:1:12 | main |
| test.rs:1:1:1:11 | foo |

View File

@@ -0,0 +1,5 @@
import rust
from Function f
where exists(f.getLocation().getFile().getRelativePath())
select f

View File

@@ -0,0 +1 @@
fn main() {}

View File

@@ -0,0 +1 @@
fn foo() {}

View File

@@ -0,0 +1,5 @@
dependencies:
codeql/rust-queries: '*'
codeql/rust-all: '*'
extractor: rust
warnOnImplicitThis: true

View File

@@ -0,0 +1,14 @@
# these tests are meant to exercise QL test running on multiple platforms
# therefore they don't rely on integration test built-in QL test running
# (which skips `qltest.{sh,cmd}`)
def test_lib(codeql, rust, cwd):
codeql.test.run("lib", threads=1)
def test_main(codeql, rust):
codeql.test.run("main", threads=1)
def test_failing_cargo_check(codeql, rust):
out = codeql.test.run("failing_cargo_check", threads=1, show_extractor_output=True,
_assert_failure=True, _capture="stderr")
assert "requested cargo check failed" in out

View File

@@ -3,7 +3,7 @@
set "RUST_BACKTRACE=full"
set "QLTEST_LOG=%CODEQL_EXTRACTOR_RUST_LOG_DIR%/qltest.log"
type NUL && "%CODEQL_EXTRACTOR_RUST_ROOT%/tools/%CODEQL_PLATFORM%/extractor" --qltest >"%QLTEST_LOG%"
type NUL && "%CODEQL_EXTRACTOR_RUST_ROOT%/tools/%CODEQL_PLATFORM%/extractor" --qltest >"%QLTEST_LOG%" 2>&1
if %ERRORLEVEL% neq 0 (
type "%QLTEST_LOG%"

View File

@@ -4,7 +4,7 @@ set -eu
export RUST_BACKTRACE=full
QLTEST_LOG="$CODEQL_EXTRACTOR_RUST_LOG_DIR"/qltest.log
if ! "$CODEQL_EXTRACTOR_RUST_ROOT/tools/$CODEQL_PLATFORM/extractor" --qltest &>> "$QLTEST_LOG"; then
if ! "$CODEQL_EXTRACTOR_RUST_ROOT/tools/$CODEQL_PLATFORM/extractor" --qltest >> "$QLTEST_LOG" 2>&1; then
cat "$QLTEST_LOG"
exit 1
fi