mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Rust: first running tests
This commit is contained in:
@@ -2,8 +2,6 @@ load("//misc/bazel:pkg.bzl", "codeql_pkg_files")
|
||||
|
||||
codeql_pkg_files(
|
||||
name = "tools",
|
||||
exes = [
|
||||
"index.sh",
|
||||
],
|
||||
exes = glob(["*.sh"]),
|
||||
visibility = ["//rust:__pkg__"],
|
||||
)
|
||||
|
||||
5
rust/tools/index-files.sh
Executable file
5
rust/tools/index-files.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -eu
|
||||
|
||||
exec "$CODEQL_EXTRACTOR_RUST_ROOT/tools/$CODEQL_PLATFORM/extractor" --inputs-file="$1"
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/bash
|
||||
# TODO move this to rust code
|
||||
|
||||
inputs=($(find -name Cargo.toml))
|
||||
|
||||
if [ "${#inputs}" -eq 0 ]; then
|
||||
inputs=($(find -name rust-project.json))
|
||||
if [ "${#inputs}" -eq 0 ]; then
|
||||
inputs=($(find -name '*.rs'))
|
||||
if [ "${#inputs}" -eq 0 ]; then
|
||||
echo "no source files found" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
exec "$CODEQL_EXTRACTOR_RUST_ROOT/tools/$CODEQL_PLATFORM/extractor" "${inputs[@]}"
|
||||
32
rust/tools/qltest.sh
Executable file
32
rust/tools/qltest.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
mkdir -p "$CODEQL_EXTRACTOR_RUST_TRAP_DIR"
|
||||
|
||||
export RUST_BACKTRACE=full
|
||||
|
||||
QLTEST_LOG="$CODEQL_EXTRACTOR_RUST_LOG_DIR"/qltest.log
|
||||
|
||||
EXTRACTOR="$CODEQL_EXTRACTOR_RUST_ROOT/tools/$CODEQL_PLATFORM/extractor"
|
||||
for src in *.rs; do
|
||||
echo -e "[package]\nname = \"test\"\n[lib]\npath=\"$src\"\n" > Cargo.toml
|
||||
env=()
|
||||
opts=("$src")
|
||||
opts+=($(sed -n '1 s=//codeql-extractor-options:==p' $src))
|
||||
expected_status=$(sed -n 's=//codeql-extractor-expected-status:[[:space:]]*==p' $src)
|
||||
expected_status=${expected_status:-0}
|
||||
env+=($(sed -n '1 s=//codeql-extractor-env:==p' $src))
|
||||
echo >> $QLTEST_LOG
|
||||
echo "env ${env[@]} $EXTRACTOR ${opts[@]}" >> "$QLTEST_LOG"
|
||||
env "${env[@]}" "$EXTRACTOR" "${opts[@]}" >> $QLTEST_LOG 2>&1
|
||||
actual_status=$?
|
||||
if [[ $actual_status != $expected_status ]]; then
|
||||
FAILED=1
|
||||
fi
|
||||
done
|
||||
|
||||
rm -rf Cargo.*
|
||||
|
||||
if [ -n "$FAILED" ]; then
|
||||
cat "$QLTEST_LOG" # Show compiler errors on extraction failure
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user