-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rust: add optional dependencies to ql tests
Also accept `options.yml` and `options.yaml` files as well for test options, to get YAML syntax highlighting. In a follow up PR we might make the extension mandatory.
- Loading branch information
Paolo Tranquilli
committed
Nov 18, 2024
1 parent
63bc1ef
commit 75375be
Showing
7 changed files
with
47 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
rust/ql/integration-tests/qltest/dependencies/functions.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
| test.rs:4:1:7:1 | foo | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
qltest_cargo_check: true | ||
qltest_dependencies: | ||
- anyhow = "1.0.86" | ||
- log = "0.4.22" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use anyhow; | ||
use log::info; | ||
|
||
fn foo() -> anyhow::Result<()> { | ||
info!("logging works"); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
import runs_on | ||
import pytest | ||
|
||
# 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) | ||
@pytest.fixture(autouse=True) | ||
def default_options(codeql): | ||
codeql.flags.update( | ||
threads = 1, | ||
show_extractor_output = True, | ||
check_databases = False, | ||
) | ||
|
||
def test_main(codeql, rust): | ||
codeql.test.run("main", threads=1) | ||
@pytest.mark.parametrize("dir", ["lib", "main", "dependencies"]) | ||
def test(codeql, rust, dir): | ||
codeql.test.run(dir) | ||
|
||
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") | ||
out = codeql.test.run("failing_cargo_check", _assert_failure=True, _capture="stderr") | ||
# TODO: QL test output redirection is currently broken on windows, leaving it up for follow-up work | ||
if not runs_on.windows: | ||
assert "requested cargo check failed" in out |