From 034dd3f9cce8b1f8ee2794c8c26ba0f82b1bedfe Mon Sep 17 00:00:00 2001 From: jackfiled Date: Fri, 15 Mar 2024 14:56:41 +0800 Subject: [PATCH] feat: integration-test (#13) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加集成测试,当前只有公开测试集的70个样例。 Reviewed-on: https://git.rrricardo.top/PostGuard/Canon/pulls/13 --- .gitea/workflows/integration_test.yaml | 28 ++++ .gitignore | 4 - Canon.sln | 1 + open_set/26_op_priority4.in | 1 + open_set/30_logi_assign.in | 1 + open_set/34_short_circuit.in | 4 + open_set/40_percolation.in | 10 ++ open_set/42_color.in | 2 + open_set/44_reverse_output.in | 200 +++++++++++++++++++++++++ open_set/45_dijkstra.in | 10 ++ open_set/46_full_conn.in | 37 +++++ open_set/47_hanoi.in | 5 + open_set/48_n_queens.in | 2 + scripts/integration_test.py | 4 +- 14 files changed, 304 insertions(+), 5 deletions(-) create mode 100644 .gitea/workflows/integration_test.yaml create mode 100644 open_set/26_op_priority4.in create mode 100644 open_set/30_logi_assign.in create mode 100644 open_set/34_short_circuit.in create mode 100644 open_set/40_percolation.in create mode 100644 open_set/42_color.in create mode 100644 open_set/44_reverse_output.in create mode 100644 open_set/45_dijkstra.in create mode 100644 open_set/46_full_conn.in create mode 100644 open_set/47_hanoi.in create mode 100644 open_set/48_n_queens.in diff --git a/.gitea/workflows/integration_test.yaml b/.gitea/workflows/integration_test.yaml new file mode 100644 index 0000000..8c0211a --- /dev/null +++ b/.gitea/workflows/integration_test.yaml @@ -0,0 +1,28 @@ +name: Integration Test +on: + push: + branches: + - master + +jobs: + Open-Set-Test: + runs-on: archlinux + steps: + - name: Check out repository code + uses: https://git.rrricardo.top/actions/checkout@v4 + - name: Use nuget package cache + uses: https://git.rrricardo.top/actions/cache@v4 + with: + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget + save-always: true + - name: Build binary file + run: | + dotnet publish + cp ./Canon.Console/bin/Release/net8.0/linux-x64/publish/Canon.Console ./pacss + - name: Build open set binary + run: | + python scripts/integration_test.py run + - name: Run open set test + run: | + python scripts/integration_test.py test diff --git a/.gitignore b/.gitignore index b3b092f..7a7095a 100644 --- a/.gitignore +++ b/.gitignore @@ -485,7 +485,3 @@ $RECYCLE.BIN/ # Database Source File *.db - -# Integration Generated File -open_set/** -!*.pas diff --git a/Canon.sln b/Canon.sln index 9e0ea0e..cc5d337 100644 --- a/Canon.sln +++ b/Canon.sln @@ -20,6 +20,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{EAA3629C-CD74-4E1F-A7F8-76D1FF0EC925}" ProjectSection(SolutionItems) = preProject .gitea\workflows\test.yaml = .gitea\workflows\test.yaml + .gitea\workflows\integration_test.yaml = .gitea\workflows\integration_test.yaml EndProjectSection EndProject Global diff --git a/open_set/26_op_priority4.in b/open_set/26_op_priority4.in new file mode 100644 index 0000000..ecfbc7c --- /dev/null +++ b/open_set/26_op_priority4.in @@ -0,0 +1 @@ +0 1 1 1 1 diff --git a/open_set/30_logi_assign.in b/open_set/30_logi_assign.in new file mode 100644 index 0000000..f4eea7b --- /dev/null +++ b/open_set/30_logi_assign.in @@ -0,0 +1 @@ +4 4 \ No newline at end of file diff --git a/open_set/34_short_circuit.in b/open_set/34_short_circuit.in new file mode 100644 index 0000000..71f0f6a --- /dev/null +++ b/open_set/34_short_circuit.in @@ -0,0 +1,4 @@ +11 +10 +100 +99 \ No newline at end of file diff --git a/open_set/40_percolation.in b/open_set/40_percolation.in new file mode 100644 index 0000000..5894c8d --- /dev/null +++ b/open_set/40_percolation.in @@ -0,0 +1,10 @@ +2 2 +3 1 +4 2 +4 4 +1 2 +2 3 +2 1 +3 2 +3 4 +3 1 \ No newline at end of file diff --git a/open_set/42_color.in b/open_set/42_color.in new file mode 100644 index 0000000..36826c2 --- /dev/null +++ b/open_set/42_color.in @@ -0,0 +1,2 @@ +5 +2 2 2 2 2 \ No newline at end of file diff --git a/open_set/44_reverse_output.in b/open_set/44_reverse_output.in new file mode 100644 index 0000000..07784f8 --- /dev/null +++ b/open_set/44_reverse_output.in @@ -0,0 +1,200 @@ +0 +3 +6 +9 +12 +15 +18 +21 +24 +27 +30 +33 +36 +39 +42 +45 +48 +51 +54 +57 +60 +63 +66 +69 +72 +75 +78 +81 +84 +87 +90 +93 +96 +99 +102 +105 +108 +111 +114 +117 +120 +123 +126 +129 +132 +135 +138 +141 +144 +147 +150 +153 +156 +159 +162 +165 +168 +171 +174 +177 +180 +183 +186 +189 +192 +195 +198 +201 +204 +207 +210 +213 +216 +219 +222 +225 +228 +231 +234 +237 +240 +243 +246 +249 +252 +255 +258 +261 +264 +267 +270 +273 +276 +279 +282 +285 +288 +291 +294 +297 +300 +303 +306 +309 +312 +315 +318 +321 +324 +327 +330 +333 +336 +339 +342 +345 +348 +351 +354 +357 +360 +363 +366 +369 +372 +375 +378 +381 +384 +387 +390 +393 +396 +399 +402 +405 +408 +411 +414 +417 +420 +423 +426 +429 +432 +435 +438 +441 +444 +447 +450 +453 +456 +459 +462 +465 +468 +471 +474 +477 +480 +483 +486 +489 +492 +495 +498 +501 +504 +507 +510 +513 +516 +519 +522 +525 +528 +531 +534 +537 +540 +543 +546 +549 +552 +555 +558 +561 +564 +567 +570 +573 +576 +579 +582 +585 +588 +591 +594 +597 \ No newline at end of file diff --git a/open_set/45_dijkstra.in b/open_set/45_dijkstra.in new file mode 100644 index 0000000..5dc7677 --- /dev/null +++ b/open_set/45_dijkstra.in @@ -0,0 +1,10 @@ +6 9 +1 2 1 +2 3 9 +1 3 12 +2 4 3 +4 3 4 +3 5 5 +4 5 13 +5 6 4 +4 6 15 diff --git a/open_set/46_full_conn.in b/open_set/46_full_conn.in new file mode 100644 index 0000000..17900c4 --- /dev/null +++ b/open_set/46_full_conn.in @@ -0,0 +1,37 @@ +6 + +1 2 3 4 5 +5 6 7 8 9 +9 8 7 6 5 +4 3 2 1 1 +1 1 5 9 4 + +1 1 1 1 1 +1 1 1 1 1 +1 1 1 1 1 +1 1 1 1 1 +1 1 1 1 1 + +1 1 1 1 1 +2 2 2 2 2 +3 3 3 3 3 +4 4 4 4 4 +5 5 5 5 5 + +1 2 3 4 5 +1 2 3 4 5 +1 2 3 4 5 +1 2 3 4 5 +1 2 3 4 5 + +5 4 3 2 1 +5 4 3 2 1 +5 4 3 2 1 +5 4 3 2 1 +5 4 3 2 1 + +1 2 3 2 1 +4 5 6 5 4 +7 8 9 8 7 +4 5 6 5 4 +1 2 3 2 1 diff --git a/open_set/47_hanoi.in b/open_set/47_hanoi.in new file mode 100644 index 0000000..76dbb71 --- /dev/null +++ b/open_set/47_hanoi.in @@ -0,0 +1,5 @@ +4 +4 +7 +3 +9 diff --git a/open_set/48_n_queens.in b/open_set/48_n_queens.in new file mode 100644 index 0000000..0e3efec --- /dev/null +++ b/open_set/48_n_queens.in @@ -0,0 +1,2 @@ +4 +1 5 6 8 \ No newline at end of file diff --git a/scripts/integration_test.py b/scripts/integration_test.py index bd25f78..327b32e 100644 --- a/scripts/integration_test.py +++ b/scripts/integration_test.py @@ -53,6 +53,7 @@ def run_binary(): binary_files = compile_files() for pair in binary_files: print("Info: run " + pair[0]) + print(pair[1]) pascal_result = "open_set/" + pair[0] + ".pas_result" c_result = "open_set/" + pair[0] + ".c_result" @@ -99,7 +100,8 @@ def check_result(): print("C: ", c_result) print(str(pass_result) + "/" + str(len(tests)) + " tests passed!") - + if pass_result != len(tests): + sys.exit(-1) if __name__ == "__main__": if sys.argv[1] == "run":