Skip to content

Commit efcb9e0

Browse files
authored
Merge pull request #72 from codefuse-ai/lhk_dev
[fix] fix godel script test
2 parents feec382 + 5412488 commit efcb9e0

File tree

3 files changed

+9
-140
lines changed

3 files changed

+9
-140
lines changed

example/xml/GetBean.gdl

-56
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,6 @@
11
// script
22
use coref::xml::*
33

4-
schema BeanXmlElement extends XmlElement {}
5-
6-
impl BeanXmlElement {
7-
@data_constraint
8-
pub fn __all__(db: XmlDB) -> *BeanXmlElement {
9-
for (e in XmlElement(db)) {
10-
let (path = e.getLocation().getFile().getRelativePath()) {
11-
if (!path.contains("target") && e.getName() = "bean") {
12-
yield BeanXmlElement {
13-
id: e.id,
14-
location_id: e.location_id,
15-
parent_id: e.parent_id,
16-
index_order: e.index_order
17-
}
18-
}
19-
}
20-
}
21-
}
22-
}
23-
24-
schema EntryXmlElement extends XmlElement {}
25-
26-
impl EntryXmlElement {
27-
@data_constraint
28-
fn __all__(db: XmlDB) -> *EntryXmlElement {
29-
for (e in XmlElement(db)) {
30-
if (e.getName() = "entry") {
31-
yield EntryXmlElement {
32-
id: e.id,
33-
location_id: e.location_id,
34-
parent_id: e.parent_id,
35-
index_order: e.index_order
36-
}
37-
}
38-
}
39-
}
40-
}
41-
42-
schema PropertyXmlElement extends XmlElement {}
43-
44-
impl PropertyXmlElement {
45-
@data_constraint
46-
fn __all__(db: XmlDB) -> *PropertyXmlElement {
47-
for (e in XmlElement(db)) {
48-
if (e.getName() = "property") {
49-
yield PropertyXmlElement {
50-
id: e.id,
51-
location_id: e.location_id,
52-
parent_id: e.parent_id,
53-
index_order: e.index_order
54-
}
55-
}
56-
}
57-
}
58-
}
59-
604
fn default_db() -> XmlDB {
615
return XmlDB::load("coref_xml_src.db")
626
}

example/xml/POM.gdl

-17
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,6 @@ impl ArtifactElement {
7373
}
7474
}
7575

76-
schema PomFile extends XmlFile {}
77-
78-
impl PomFile {
79-
@data_constraint
80-
pub fn __all__(db: XmlDB) -> *PomFile {
81-
for(f in XmlFile(db)) {
82-
if (f.getFileName() = "pom.xml") {
83-
yield PomFile {
84-
id: f.id,
85-
file_name: f.file_name,
86-
relative_path: f.relative_path
87-
}
88-
}
89-
}
90-
}
91-
}
92-
9376
// output relative path of the file, referenced jar name and version
9477
fn out(fileName: string, m1: string, m2: string, m3: string) -> bool {
9578
let (db = XmlDB::load("coref_xml_src.db")) {

tool/aci/check_gdl.sh

+9-67
Original file line numberDiff line numberDiff line change
@@ -44,72 +44,13 @@ fi
4444
cd "$1" || exit 1
4545

4646
sparrow_godel_script="$HOME/sparrow-cli/sparrow-cli/godel-script/usr/bin/godel"
47-
sparrow_lib_1_0="$HOME/sparrow-cli/sparrow-cli/lib-1.0"
47+
sparrow_lib="$HOME/sparrow-cli/sparrow-cli/lib"
4848

4949
# Define get_files function
5050
get_files() {
5151
find "$1" -type f \( -name "*$2" \) -print
5252
}
5353

54-
# Define rebuild_lib function
55-
rebuild_lib() {
56-
local lib_path="$1"
57-
local lib="$2"
58-
local gdl_list=()
59-
local output_file
60-
local tmp_out
61-
local start_time
62-
local end_time
63-
local elapsed_time
64-
65-
gdl_list+=($(get_files "$lib_path" ".gs"))
66-
gdl_list+=($(get_files "$lib_path" ".gdl"))
67-
68-
output_file=$(mktemp "tempfile.XXXXXX.gdl")
69-
trap 'rm -f "$output_file"' EXIT
70-
71-
echo "// script" > "$output_file"
72-
for file_name in "${gdl_list[@]}"; do
73-
cat "$file_name" >> "$output_file"
74-
done
75-
76-
tmp_out=$(mktemp "tempfile.XXXXXX.gdl")
77-
trap 'rm -f "$tmp_out"' EXIT
78-
79-
start_time=$(date +%s%3N)
80-
if ! "$sparrow_godel_script" "$output_file" -o "$tmp_out"; then
81-
echo "$lib_path lib compile error, please check it yourself" >&2
82-
exit 1
83-
fi
84-
85-
mv "$tmp_out" "$sparrow_lib_1_0/coref.$lib.gdl"
86-
87-
end_time=$(date +%s%3N)
88-
elapsed_time=$((end_time - start_time))
89-
echo "$lib_path lib compile success time: ${elapsed_time} milliseconds" >&2
90-
}
91-
92-
# Define get_language function
93-
get_language() {
94-
local dir="$1"
95-
local dirname
96-
local language
97-
98-
dirname=$(dirname "$dir")
99-
language=$(basename "$dirname")
100-
echo "$language"
101-
}
102-
103-
# Get libs directories
104-
directories=($(find "$PWD" -type d \( -path "$PWD/language/*/lib" -o -path "$PWD/language/*/libs" \) -print))
105-
106-
# Get libs
107-
for dir in "${directories[@]}"; do
108-
lang=$(get_language "$dir")
109-
echo "Building lib for $lang ..."
110-
rebuild_lib "$dir" "$lang"
111-
done
112-
11354
# Define get_target_files function
11455
get_target_files() {
11556
find "$1" -type f \( -name "*.gs" -o -name "*.gdl" \) -not -name "tempfile.*.gdl" -not -path "$1/language/*/lib/*"
@@ -119,20 +60,21 @@ files=$(get_target_files "$PWD")
11960

12061
# Iterate over the files
12162
for file in $files; do
122-
output=$(("$sparrow_godel_script" "$file" -p "$sparrow_lib_1_0" -o "${file%.*}_tmp.gdl") 2>&1)
63+
output=$(("$sparrow_godel_script" "$file" -p "$sparrow_lib" --semantic-only) 2>&1)
64+
result=$?
12365
124-
# Check if the output is not empty
12566
if [ -n "$output" ]; then
126-
echo "The file $file produced the following output:"
67+
echo "File $file produced the following output:"
12768
echo "$output"
128-
echo "Please check if this file is a godel script (.gs) or a godel 1.0 script (.gdl)"
69+
fi
70+
71+
# Check if the output is not empty
72+
if [ $result -ne 0 ]; then
73+
echo "Build failed, please check this file"
12974
exit 1
13075
else
13176
echo "$file build successful"
13277
fi
133-
134-
# Remove temporary file
135-
rm -f "${file%.*}_tmp.gdl"
13678
done
13779
13880
exit 0

0 commit comments

Comments
 (0)