Skip to content
This repository was archived by the owner on Jan 8, 2023. It is now read-only.

Commit c25e69c

Browse files
author
ApsarasX
committed
test: add more test cases and improve test process
1 parent 17a1b42 commit c25e69c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+435
-311
lines changed
Lines changed: 82 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build
1+
name: Continuous Integration
22

33
on:
44
push:
@@ -43,7 +43,7 @@ jobs:
4343
CC: ${{ matrix.compiler.cc }}
4444
CXX: ${{ matrix.compiler.cxx }}
4545
run: |
46-
thread_count=`sudo cat /proc/cpuinfo| grep "processor"| wc -l`
46+
echo "THREAD_COUNT=$(sudo cat /proc/cpuinfo| grep "processor"| wc -l)" >> $GITHUB_ENV
4747
sudo mkdir -p thirdparty/antlr && cd thirdparty/antlr
4848
sudo wget https://www.antlr.org/download/antlr-4.8-complete.jar
4949
sudo wget -O ${{ runner.temp }}/antlr4-src.zip https://www.antlr.org/download/antlr4-cpp-runtime-4.8-source.zip
@@ -52,7 +52,7 @@ jobs:
5252
sudo mkdir build && cd build
5353
sudo mkdir -p ${{ github.workspace }}/thirdparty/antlr-runtime
5454
sudo cmake .. -DANTLR4_INSTALL=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-w" -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/thirdparty/antlr-runtime
55-
sudo cmake --build . --target install -- -j $thread_count
55+
sudo cmake --build . --target install -- -j $THREAD_COUNT
5656
- name: Move Antlr Runtime into /usr/local
5757
run: |
5858
cd ${{ github.workspace }}/thirdparty/antlr-runtime
@@ -63,24 +63,27 @@ jobs:
6363
CC: ${{ matrix.compiler.cc }}
6464
CXX: ${{ matrix.compiler.cxx }}
6565
run: |
66-
thread_count=`sudo cat /proc/cpuinfo| grep "processor"| wc -l`
6766
sudo mkdir cmake-build-debug cmake-build-release
6867
cd cmake-build-debug
6968
sudo cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-w" -G "Unix Makefiles" ..
70-
sudo cmake --build . --target staticscript document -- -j $thread_count
71-
for file in ../examples/*.ss
72-
do
73-
sudo ./lib/staticscript $file --emit-llvm -o ss-ir.ll
74-
sudo ./lib/staticscript $file -o ss-obj.o
75-
done
69+
sudo cmake --build . --target staticscript document -- -j $THREAD_COUNT
7670
cd ../cmake-build-release
7771
sudo cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-w" -G "Unix Makefiles" ..
78-
sudo cmake --build . --target staticscript document -- -j $thread_count
79-
for file in ../examples/*.ss
80-
do
81-
sudo ./lib/staticscript $file --emit-llvm -o ss-ir.ll
82-
sudo ./lib/staticscript $file -o ss-obj.o
83-
done
72+
sudo cmake --build . --target staticscript document -- -j $THREAD_COUNT
73+
- name: Upload Debug Executable File
74+
uses: actions/upload-artifact@v2
75+
with:
76+
name: staticscript-${{ matrix.os }}-${{ matrix.compiler.cc }}-debug
77+
path: |
78+
cmake-build-debug/staticscript
79+
cmake-build-debug/lib/*.bc
80+
- name: Upload Release Executable File
81+
uses: actions/upload-artifact@v2
82+
with:
83+
name: staticscript-${{ matrix.os }}-${{ matrix.compiler.cc }}-release
84+
path: |
85+
cmake-build-release/staticscript
86+
cmake-build-release/lib/*.bc
8487
8588
build_on_macos:
8689
name: Build on macOS
@@ -101,21 +104,73 @@ jobs:
101104
CC: ${{ matrix.compiler.cc }}
102105
CXX: ${{ matrix.compiler.cxx }}
103106
run: |
104-
thread_count=`sudo sysctl -n machdep.cpu.thread_count`
107+
echo "THREAD_COUNT=$(sudo sysctl -n machdep.cpu.thread_count)" >> $GITHUB_ENV
105108
sudo mkdir cmake-build-debug cmake-build-release
106109
cd cmake-build-debug
107110
sudo cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-w" -G "Unix Makefiles" ..
108-
sudo cmake --build . --target staticscript document -- -j $thread_count
109-
for file in ../examples/*.ss
110-
do
111-
sudo ./lib/staticscript $file --emit-llvm -o ss-ir.ll
112-
sudo ./lib/staticscript $file -o ss-obj.o
113-
done
111+
sudo cmake --build . --target staticscript document -- -j $THREAD_COUNT
114112
cd ../cmake-build-release
115113
sudo cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-w" -G "Unix Makefiles" ..
116-
sudo cmake --build . --target staticscript document -- -j $thread_count
117-
for file in ../examples/*.ss
114+
sudo cmake --build . --target staticscript document -- -j $THREAD_COUNT
115+
- name: Upload Debug Executable File
116+
uses: actions/upload-artifact@v2
117+
with:
118+
name: staticscript-${{ matrix.os }}-${{ matrix.compiler.cc }}-debug
119+
path: |
120+
cmake-build-debug/staticscript
121+
cmake-build-debug/lib/*.bc
122+
- name: Upload Release Executable File
123+
uses: actions/upload-artifact@v2
124+
with:
125+
name: staticscript-${{ matrix.os }}-${{ matrix.compiler.cc }}-release
126+
path: |
127+
cmake-build-release/staticscript
128+
cmake-build-release/lib/*.bc
129+
130+
test:
131+
name: Test
132+
needs: [ build_on_linux, build_on_macos ]
133+
runs-on: ${{ matrix.os }}
134+
strategy:
135+
matrix:
136+
os: [ ubuntu-18.04, ubuntu-20.04, macos-10.15, macos-11.0 ]
137+
compiler:
138+
- { cc: gcc, cxx: g++ }
139+
- { cc: clang, cxx: clang++ }
140+
steps:
141+
- name: Fetch Codebase
142+
uses: actions/checkout@v2
143+
- name: Download Debug Executable File
144+
uses: actions/download-artifact@v2
145+
with:
146+
name: staticscript-${{ matrix.os }}-${{ matrix.compiler.cc }}-debug
147+
path: executables/debug
148+
- name: Download Release Executable File
149+
uses: actions/download-artifact@v2
150+
with:
151+
name: staticscript-${{ matrix.os }}-${{ matrix.compiler.cc }}-release
152+
path: executables/release
153+
- name: Test Exmaple Code on Debug Compiler
154+
working-directory: executables/debug
155+
run: |
156+
chmod +x ./staticscript
157+
for file in ${{ github.workspace }}/tests/*.ss
158+
do
159+
base=$(basename $file)
160+
sudo ./staticscript $file -L lib --emit-llvm -o $base.ll
161+
sudo ./staticscript $file -L lib -o $base.o
162+
sudo clang $base.o -lm -o $base.exe
163+
sudo ./$base.exe
164+
done
165+
- name: Test Exmaple Code on Release Compiler
166+
working-directory: executables/release
167+
run: |
168+
chmod +x ./staticscript
169+
for file in ${{ github.workspace }}/tests/*.ss
118170
do
119-
sudo ./lib/staticscript $file --emit-llvm -o ss-ir.ll
120-
sudo ./lib/staticscript $file -o ss-obj.o
171+
base=$(basename $file)
172+
sudo ./staticscript $file -L lib --emit-llvm -o $base.ll
173+
sudo ./staticscript $file -L lib -o $base.o
174+
sudo clang $base.o -lm -o $base.exe
175+
sudo ./$base.exe
121176
done

CMakeLists.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,21 @@ include_directories(${PROJECT_BINARY_DIR}/include)
2727

2828
include_directories(include)
2929

30-
add_subdirectory(builtin)
30+
add_subdirectory(lib)
3131

32-
add_subdirectory(lib)
32+
add_subdirectory(src)
33+
34+
add_executable(
35+
staticscript
36+
$<TARGET_OBJECTS:parser>
37+
$<TARGET_OBJECTS:entity>
38+
$<TARGET_OBJECTS:ast>
39+
$<TARGET_OBJECTS:sema>
40+
$<TARGET_OBJECTS:codegen>
41+
$<TARGET_OBJECTS:optimization>
42+
$<TARGET_OBJECTS:driver>
43+
)
44+
45+
add_dependencies(staticscript antlr4_static)
46+
47+
target_link_libraries(staticscript PRIVATE antlr4_static ${llvm_libs})

builtin/CMakeLists.txt

Lines changed: 0 additions & 16 deletions
This file was deleted.

examples/all.ss

Lines changed: 0 additions & 29 deletions
This file was deleted.

examples/array.ss

Lines changed: 0 additions & 17 deletions
This file was deleted.

examples/iteration.ss

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)