@@ -3,19 +3,26 @@ set -euo pipefail
33
44# # Parse command line arguments
55LANGUAGE=" "
6+ SCOPE=" "
67
78usage () {
89 cat << EOF
910Usage: $0 [OPTIONS]
1011
1112Extract test databases for CodeQL queries associated with the MCP server.
1213
14+ By default, only databases needed by client integration tests are extracted
15+ (currently: javascript/examples only). Query unit tests (codeql test run)
16+ auto-extract their own databases, so full extraction is rarely needed.
17+
1318OPTIONS:
14- --language <lang> Extract databases only for the specified language
19+ --scope <scope> Extract databases for a specific use case
20+ Valid values:
21+ integration - Only databases needed by client integration tests (default)
22+ all - All test databases for all languages
23+ --language <lang> Extract databases only for the specified language (implies --scope all)
1524 Valid values: actions, cpp, csharp, go, java, javascript, python, ruby, rust, swift
1625 -h, --help Show this help message
17-
18- By default, the script extracts databases for all supported languages.
1926EOF
2027}
2128
@@ -25,6 +32,10 @@ while [[ $# -gt 0 ]]; do
2532 LANGUAGE=" $2 "
2633 shift 2
2734 ;;
35+ --scope)
36+ SCOPE=" $2 "
37+ shift 2
38+ ;;
2839 -h|--help)
2940 usage
3041 exit 0
@@ -37,6 +48,18 @@ while [[ $# -gt 0 ]]; do
3748 esac
3849done
3950
51+ # # Validate scope if provided
52+ if [ -n " ${SCOPE} " ]; then
53+ case " ${SCOPE} " in
54+ integration|all) ;;
55+ * )
56+ echo " Error: Invalid scope '${SCOPE} '" >&2
57+ echo " Valid scopes: integration, all" >&2
58+ exit 1
59+ ;;
60+ esac
61+ fi
62+
4063# # Validate language if provided
4164VALID_LANGUAGES=(" actions" " cpp" " csharp" " go" " java" " javascript" " python" " ruby" " rust" " swift" )
4265if [ -n " ${LANGUAGE} " ]; then
@@ -91,7 +114,14 @@ extract_test_databases() {
91114 done < <( find " ${_base_dir} /test" -mindepth 1 -maxdepth 1 -type d -print0)
92115}
93116
94- # # Extract test databases for integration tests.
117+ # # Extract test databases based on scope and language filters.
118+ # #
119+ # # Default (no flags): only databases needed by client integration tests
120+ # # (currently just server/ql/javascript/examples).
121+ # # --scope all: all languages × examples + tools.
122+ # # --language: filter to a single language (implies --scope all).
123+
124+ # --language implies --scope all for that language
95125if [ -n " ${LANGUAGE} " ]; then
96126 echo " Extracting test databases for language: ${LANGUAGE} "
97127 # Special handling for JavaScript which has both examples and tools
@@ -101,7 +131,7 @@ if [ -n "${LANGUAGE}" ]; then
101131 if [ -d " server/ql/${LANGUAGE} /tools" ]; then
102132 extract_test_databases " server/ql/${LANGUAGE} /tools"
103133 fi
104- else
134+ elif [ " ${SCOPE} " = " all " ] ; then
105135 echo " Extracting test databases for all languages..."
106136 for lang in " ${VALID_LANGUAGES[@]} " ; do
107137 # Special handling for JavaScript which has both examples and tools
112142 extract_test_databases " server/ql/${lang} /tools"
113143 fi
114144 done
145+ else
146+ echo " Extracting test databases for integration tests only..."
147+ extract_test_databases " server/ql/javascript/examples"
115148fi
116149
117150echo " INFO: Test database extraction complete!"
0 commit comments