mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Rust: fix qltest on macOS, and add CI cross-platform testing of it
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
fn foo() {
|
||||
wat
|
||||
is
|
||||
this?
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import rust
|
||||
|
||||
from Function f
|
||||
where exists(f.getLocation().getFile().getRelativePath())
|
||||
select f
|
||||
@@ -0,0 +1 @@
|
||||
qltest_cargo_check: true
|
||||
1
rust/ql/integration-tests/qltest/lib/functions.expected
Normal file
1
rust/ql/integration-tests/qltest/lib/functions.expected
Normal file
@@ -0,0 +1 @@
|
||||
| test.rs:1:1:1:11 | foo |
|
||||
5
rust/ql/integration-tests/qltest/lib/functions.ql
Normal file
5
rust/ql/integration-tests/qltest/lib/functions.ql
Normal file
@@ -0,0 +1,5 @@
|
||||
import rust
|
||||
|
||||
from Function f
|
||||
where exists(f.getLocation().getFile().getRelativePath())
|
||||
select f
|
||||
1
rust/ql/integration-tests/qltest/lib/test.rs
Normal file
1
rust/ql/integration-tests/qltest/lib/test.rs
Normal file
@@ -0,0 +1 @@
|
||||
fn foo() {}
|
||||
2
rust/ql/integration-tests/qltest/main/functions.expected
Normal file
2
rust/ql/integration-tests/qltest/main/functions.expected
Normal file
@@ -0,0 +1,2 @@
|
||||
| main.rs:1:1:1:12 | main |
|
||||
| test.rs:1:1:1:11 | foo |
|
||||
5
rust/ql/integration-tests/qltest/main/functions.ql
Normal file
5
rust/ql/integration-tests/qltest/main/functions.ql
Normal file
@@ -0,0 +1,5 @@
|
||||
import rust
|
||||
|
||||
from Function f
|
||||
where exists(f.getLocation().getFile().getRelativePath())
|
||||
select f
|
||||
1
rust/ql/integration-tests/qltest/main/main.rs
Normal file
1
rust/ql/integration-tests/qltest/main/main.rs
Normal file
@@ -0,0 +1 @@
|
||||
fn main() {}
|
||||
1
rust/ql/integration-tests/qltest/main/test.rs
Normal file
1
rust/ql/integration-tests/qltest/main/test.rs
Normal file
@@ -0,0 +1 @@
|
||||
fn foo() {}
|
||||
5
rust/ql/integration-tests/qltest/qlpack.yml
Normal file
5
rust/ql/integration-tests/qltest/qlpack.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
dependencies:
|
||||
codeql/rust-queries: '*'
|
||||
codeql/rust-all: '*'
|
||||
extractor: rust
|
||||
warnOnImplicitThis: true
|
||||
14
rust/ql/integration-tests/qltest/test.py
Normal file
14
rust/ql/integration-tests/qltest/test.py
Normal 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
|
||||
@@ -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%"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user