Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f77a8ff

Browse filesBrowse files
authored
tests : conditional python & node json schema tests (#6207)
* json: only attempt python & node schema conversion tests if their bins are present Tests introduced in #5978 disabled in #6198 * json: orange warnings when tests skipped * json: ensure py/js schema conv tested on ubuntu-focal-make * json: print env vars in test
1 parent 72114ed commit f77a8ff
Copy full SHA for f77a8ff

File tree

Expand file treeCollapse file tree

2 files changed

+36
-12
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+36
-12
lines changed

‎.github/workflows/build.yml

Copy file name to clipboardExpand all lines: .github/workflows/build.yml
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ jobs:
135135
136136
ubuntu-focal-make:
137137
runs-on: ubuntu-20.04
138+
env:
139+
LLAMA_NODE_AVAILABLE: true
140+
LLAMA_PYTHON_AVAILABLE: true
138141

139142
steps:
140143
- name: Clone
@@ -147,6 +150,14 @@ jobs:
147150
sudo apt-get update
148151
sudo apt-get install build-essential gcc-8
149152
153+
- uses: actions/setup-node@v4
154+
with:
155+
node-version: "20"
156+
157+
- uses: actions/setup-python@v4
158+
with:
159+
python-version: "3.11"
160+
150161
- name: Build
151162
id: make_build
152163
env:

‎tests/test-json-schema-to-grammar.cpp

Copy file name to clipboardExpand all lines: tests/test-json-schema-to-grammar.cpp
+25-12Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,9 @@ static void test_all(const std::string & lang, std::function<void(const TestCase
799799
}
800800

801801
int main() {
802+
fprintf(stderr, "LLAMA_NODE_AVAILABLE = %s\n", getenv("LLAMA_NODE_AVAILABLE") ? "true" : "false");
803+
fprintf(stderr, "LLAMA_PYTHON_AVAILABLE = %s\n", getenv("LLAMA_PYTHON_AVAILABLE") ? "true" : "false");
804+
802805
test_all("C++", [](const TestCase & tc) {
803806
try {
804807
tc.verify(json_schema_to_grammar(nlohmann::ordered_json::parse(tc.schema)));
@@ -808,18 +811,28 @@ int main() {
808811
tc.verify_status(FAILURE);
809812
}
810813
});
811-
//test_all("Python", [](const TestCase & tc) {
812-
// write("test-json-schema-input.tmp", tc.schema);
813-
// tc.verify_status(std::system(
814-
// "python ./examples/json-schema-to-grammar.py test-json-schema-input.tmp > test-grammar-output.tmp") == 0 ? SUCCESS : FAILURE);
815-
// tc.verify(read("test-grammar-output.tmp"));
816-
//});
817-
//test_all("JavaScript", [](const TestCase & tc) {
818-
// write("test-json-schema-input.tmp", tc.schema);
819-
// tc.verify_status(std::system(
820-
// "node ./tests/run-json-schema-to-grammar.mjs test-json-schema-input.tmp > test-grammar-output.tmp") == 0 ? SUCCESS : FAILURE);
821-
// tc.verify(read("test-grammar-output.tmp"));
822-
//});
814+
815+
if (getenv("LLAMA_PYTHON_AVAILABLE") || (std::system("python --version") == 0)) {
816+
test_all("Python", [](const TestCase & tc) {
817+
write("test-json-schema-input.tmp", tc.schema);
818+
tc.verify_status(std::system(
819+
"python ./examples/json-schema-to-grammar.py test-json-schema-input.tmp > test-grammar-output.tmp") == 0 ? SUCCESS : FAILURE);
820+
tc.verify(read("test-grammar-output.tmp"));
821+
});
822+
} else {
823+
fprintf(stderr, "\033[33mWARNING: Python not found, skipping Python JSON schema -> grammar tests.\n\033[0m");
824+
}
825+
826+
if (getenv("LLAMA_NODE_AVAILABLE") || (std::system("node --version") == 0)) {
827+
test_all("JavaScript", [](const TestCase & tc) {
828+
write("test-json-schema-input.tmp", tc.schema);
829+
tc.verify_status(std::system(
830+
"node ./tests/run-json-schema-to-grammar.mjs test-json-schema-input.tmp > test-grammar-output.tmp") == 0 ? SUCCESS : FAILURE);
831+
tc.verify(read("test-grammar-output.tmp"));
832+
});
833+
} else {
834+
fprintf(stderr, "\033[33mWARNING: Node not found, skipping JavaScript JSON schema -> grammar tests.\n\033[0m");
835+
}
823836

824837
test_all("Check Expectations Validity", [](const TestCase & tc) {
825838
if (tc.expected_status == SUCCESS) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.