Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fn foo() {
wat
is
this?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import rust

from Function f
where exists(f.getLocation().getFile().getRelativePath())
select f
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
qltest_cargo_check: true
1 change: 1 addition & 0 deletions rust/ql/integration-tests/qltest/lib/functions.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
| test.rs:1:1:1:11 | foo |
5 changes: 5 additions & 0 deletions rust/ql/integration-tests/qltest/lib/functions.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import rust

from Function f
where exists(f.getLocation().getFile().getRelativePath())
select f
1 change: 1 addition & 0 deletions rust/ql/integration-tests/qltest/lib/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn foo() {}
2 changes: 2 additions & 0 deletions rust/ql/integration-tests/qltest/main/functions.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
| main.rs:1:1:1:12 | main |
| test.rs:1:1:1:11 | foo |
5 changes: 5 additions & 0 deletions rust/ql/integration-tests/qltest/main/functions.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import rust

from Function f
where exists(f.getLocation().getFile().getRelativePath())
select f
1 change: 1 addition & 0 deletions rust/ql/integration-tests/qltest/main/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn main() {}
1 change: 1 addition & 0 deletions rust/ql/integration-tests/qltest/main/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn foo() {}
5 changes: 5 additions & 0 deletions rust/ql/integration-tests/qltest/qlpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dependencies:
codeql/rust-queries: '*'
codeql/rust-all: '*'
extractor: rust
warnOnImplicitThis: true
14 changes: 14 additions & 0 deletions rust/ql/integration-tests/qltest/test.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion rust/tools/qltest.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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%"
Expand Down
2 changes: 1 addition & 1 deletion rust/tools/qltest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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