|
| 1 | +#!/usr/bin/env just --justfile |
| 2 | + |
| 3 | +set allow-duplicate-recipes |
| 4 | +set allow-duplicate-variables |
| 5 | +set unstable |
| 6 | +set quiet |
| 7 | + |
| 8 | +_install LANGUAGE: |
| 9 | + bazel run //{{ trim_end_match(LANGUAGE, '/') }}:install |
| 10 | + |
| 11 | +_build LANGUAGE: |
| 12 | + if [ -n ${SEMMLE_CODE:-} ]; then \ |
| 13 | + cd $SEMMLE_CODE; ./build target/intree/codeql-{{ LANGUAGE }}; \ |
| 14 | + else \ |
| 15 | + just install {{ LANGUAGE }}; \ |
| 16 | + fi |
| 17 | + |
| 18 | +build LANGUAGE: (_build LANGUAGE) |
| 19 | +install LANGUAGE: (_install LANGUAGE) |
| 20 | + |
| 21 | +[no-cd, script:'python3', positional-arguments, no-exit-message] |
| 22 | +test +ARGS: # TODO: fuzzy test chooser when no arguments are provided! |
| 23 | + import pathlib |
| 24 | + import subprocess |
| 25 | + import os |
| 26 | + import sys |
| 27 | + # avoid infinite recursion: this happens when arguments have kinds of tests |
| 28 | + if os.environ.get("CODEQL_JUSTFILE_TEST"): |
| 29 | + print("No common test handler found", file=sys.stderr) |
| 30 | + sys.exit(1) |
| 31 | + os.environ["CODEQL_JUSTFILE_TEST"] = "true" |
| 32 | + |
| 33 | + flags = [arg for arg in sys.argv[1:] if arg.startswith('-')] |
| 34 | + args = [arg for arg in sys.argv[1:] if not arg.startswith('-')] |
| 35 | + common_path = pathlib.Path(os.path.commonpath(args)).resolve() |
| 36 | + if not common_path.is_dir(): |
| 37 | + common_path = common_path.parent |
| 38 | + ret = subprocess.run( |
| 39 | + ['{{ just_executable() }}', 'test'] + flags + [pathlib.Path(a).resolve().relative_to(common_path) for a in args], |
| 40 | + cwd=common_path).returncode |
| 41 | + sys.exit(ret) |
| 42 | + |
| 43 | +[no-cd] |
| 44 | +_run_language_tests LANGUAGE *ARGS: (_build LANGUAGE) |
| 45 | + if [ -n ${SEMMLE_CODE:-} ]; then \ |
| 46 | + $SEMMLE_CODE/target/intree/codeql-{{ LANGUAGE }}/codeql test run $ARGS; \ |
| 47 | + else \ |
| 48 | + codeql --search-path={{ source_dir() }} test run $ARGS; \ |
| 49 | + fi |
| 50 | + |
| 51 | +[no-cd] |
| 52 | +_run_integration_tests *ARGS: |
| 53 | + if [ -n ${SEMMLE_CODE:-} ]; then \ |
| 54 | + $SEMMLE_CODE/tools/pytest $ARGS; \ |
| 55 | + else \ |
| 56 | + echo "integration tests require running from an internal repository working copy" >&2; \ |
| 57 | + exit 1; \ |
| 58 | + fi |
0 commit comments