@@ -3,19 +3,27 @@ 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 a minimal set of databases for client integration tests is
15+ pre-extracted (currently: javascript/examples only). This is not an
16+ exhaustive list of databases the integration test suite may use; additional
17+ databases may be extracted on demand, so full extraction is rarely needed.
18+
1319OPTIONS:
14- --language <lang> Extract databases only for the specified language
20+ --scope <scope> Extract databases for a specific use case
21+ Valid values:
22+ integration - Only databases needed by client integration tests (default)
23+ all - All test databases for all languages
24+ --language <lang> Extract databases only for the specified language (implies --scope all)
1525 Valid values: actions, cpp, csharp, go, java, javascript, python, ruby, rust, swift
1626 -h, --help Show this help message
17-
18- By default, the script extracts databases for all supported languages.
1927EOF
2028}
2129
@@ -25,6 +33,10 @@ while [[ $# -gt 0 ]]; do
2533 LANGUAGE=" $2 "
2634 shift 2
2735 ;;
36+ --scope)
37+ SCOPE=" $2 "
38+ shift 2
39+ ;;
2840 -h|--help)
2941 usage
3042 exit 0
@@ -37,6 +49,18 @@ while [[ $# -gt 0 ]]; do
3749 esac
3850done
3951
52+ # # Validate scope if provided
53+ if [ -n " ${SCOPE} " ]; then
54+ case " ${SCOPE} " in
55+ integration|all) ;;
56+ * )
57+ echo " Error: Invalid scope '${SCOPE} '" >&2
58+ echo " Valid scopes: integration, all" >&2
59+ exit 1
60+ ;;
61+ esac
62+ fi
63+
4064# # Validate language if provided
4165VALID_LANGUAGES=(" actions" " cpp" " csharp" " go" " java" " javascript" " python" " ruby" " rust" " swift" )
4266if [ -n " ${LANGUAGE} " ]; then
@@ -91,7 +115,14 @@ extract_test_databases() {
91115 done < <( find " ${_base_dir} /test" -mindepth 1 -maxdepth 1 -type d -print0)
92116}
93117
94- # # Extract test databases for integration tests.
118+ # # Extract test databases based on scope and language filters.
119+ # #
120+ # # Default (no flags): only databases needed by client integration tests
121+ # # (currently just server/ql/javascript/examples).
122+ # # --scope all: all languages × examples + tools.
123+ # # --language: filter to a single language (implies --scope all).
124+
125+ # --language implies --scope all for that language
95126if [ -n " ${LANGUAGE} " ]; then
96127 echo " Extracting test databases for language: ${LANGUAGE} "
97128 # Special handling for JavaScript which has both examples and tools
@@ -101,7 +132,7 @@ if [ -n "${LANGUAGE}" ]; then
101132 if [ -d " server/ql/${LANGUAGE} /tools" ]; then
102133 extract_test_databases " server/ql/${LANGUAGE} /tools"
103134 fi
104- else
135+ elif [ " ${SCOPE} " = " all " ] ; then
105136 echo " Extracting test databases for all languages..."
106137 for lang in " ${VALID_LANGUAGES[@]} " ; do
107138 # Special handling for JavaScript which has both examples and tools
112143 extract_test_databases " server/ql/${lang} /tools"
113144 fi
114145 done
146+ else
147+ echo " Extracting test databases for integration tests only..."
148+ extract_test_databases " server/ql/javascript/examples"
115149fi
116150
117151echo " INFO: Test database extraction complete!"
0 commit comments