demo: add gogen package_test comprehensive test suite#1605
demo: add gogen package_test comprehensive test suite#1605luoliwoshang wants to merge 3 commits intogoplus:mainfrom
Conversation
Summary of ChangesHello @luoliwoshang, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly expands the testing infrastructure for the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Ignored Files
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
5c64e3a to
90ae47a
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces several significant enhancements. A comprehensive test suite for gogen is added to validate llgo's compatibility. The build system is improved with a new -x flag to print commands and a more flexible build.sh script. A major part of this PR is the implementation of defer and panic support for baremetal targets using setjmp/longjmp. Additionally, interface assertion logic is made more robust to handle methods that might be stripped by dead code elimination. The changes are well-structured and include relevant tests. My review found one area for improvement in a shell script to reduce code duplication.
I am having trouble creating individual review comments. Click here to see my feedback.
_demo/embed/targetsbuild/build.sh (101-178)
The ignore_list definitions for empty and defer share a large number of common targets. To improve maintainability and reduce duplication, you could define a common list of ignored targets and then append test-specific ones.
# Define common ignore list
common_ignore_list=(
"atmega1280"
"atmega2560"
"atmega328p"
"atmega32u4"
"attiny85"
"fe310"
"k210"
"riscv32"
"riscv64"
"rp2040"
)
# Define ignore list based on test directory
case "$test_dir" in
empty)
ignore_list=("${common_ignore_list[@]}")
;;
defer)
ignore_list=(
"${common_ignore_list[@]}"
# <unknown>:0: error: out of range branch target (expected an integer in the range -4096 to 4095)
# error: cannot compile inline asm
"digispark"
#In file included from /home/runner/work/llgo/llgo/runtime/internal/clite/debug/_wrap/debug.c:9:
# In file included from /usr/include/dlfcn.h:22:
# In file included from /usr/include/features.h:394:
# /usr/include/features-time64.h:20:10: fatal error: 'bits/wordsize.h' file not found
# 20 | #include <bits/wordsize.h>
# | ^~~~~~~~~~~~~~~~~
# 1 error generated.
# panic: exit status 1
"nintendoswitch"
# ld.lld: error: /home/runner/.cache/llgo/crosscompile/picolibc-v0.1.0/libc-avr.a(-home-runner-.cache-llgo-crosscompile-picolibc-v0.1.0-newlib-libc-tinystdio-printf.c1170247836.o): cannot link object files with incompatible target ISA
"simavr"
# libc symbol lack
"arduino-leonardo"
"arduino-mega1280"
"arduino-mega2560"
"arduino-nano-new"
"arduino-nano"
"arduino"
"atmega1284p"
"atmega328pb"
"attiny1616"
"cortex-m0"
"cortex-m0plus"
"cortex-m3"
"cortex-m33"
"cortex-m4"
"cortex-m7"
"d1mini"
"esp8266"
"gameboy-advance"
"hifive1b"
"maixbit"
"nodemcu"
"riscv-qemu"
"riscv32-esp"
"stm32l0x2"
"tkey"
)
;;
*)
echo "Error: Unknown test directory '$test_dir'. Please add ignore_list in build.sh."
exit 1
;;
esac
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1605 +/- ##
==========================================
+ Coverage 91.00% 91.06% +0.05%
==========================================
Files 45 45
Lines 11927 11938 +11
==========================================
+ Hits 10854 10871 +17
+ Misses 898 892 -6
Partials 175 175 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@xgopilot test_demo.sh add the _demo/gogen folder! |
Completed @luoliwoshang's requestAdded Changes made:
PR created: luoliwoshang#191 Please merge this PR to include the changes in your branch. |
Code Review SummaryThis PR adds a comprehensive gogen package test suite demonstrating llgo's compatibility with gogen's code generation APIs. The changes include:
Critical Issue FoundCompilation Error: The Areas Reviewed
The baremetal defer support and interface method lookup changes are well-designed. The new jump buffer sizes for ARM, AVR, Cortex-M, RISC-V, and Xtensa architectures include proper source references to picolibc/newlib. See inline comments for specific issues. |
_demo/gogen/package_test.go
Outdated
| testTypeSwitch() | ||
| fmt.Println() | ||
|
|
||
| testTypeSwitch2() |
There was a problem hiding this comment.
Critical: Compilation Error
This calls testTypeSwitch2() which is commented out (lines 858-885). This will cause a compilation error:
undefined: testTypeSwitch2
Since the test is marked as IGNORED due to a known bug (issue #1604), this call should be removed:
| testTypeSwitch2() | |
| // testTypeSwitch2() - IGNORED: see https://github.com/goplus/llgo/issues/1604 |
_demo/gogen/package/package.go
Outdated
| // Converted from package_test.go for llgo testing | ||
| // Batch 1: tests 1-5, Batch 2: tests 6-15 |
There was a problem hiding this comment.
Minor: Batch comment incomplete
The header says "Batch 1: tests 1-5, Batch 2: tests 6-15" but the file contains tests up to 29 (with test 29 ignored). Consider updating:
| // Converted from package_test.go for llgo testing | |
| // Batch 1: tests 1-5, Batch 2: tests 6-15 | |
| // Converted from package_test.go for llgo testing | |
| // Tests 1-28 active, Test 29 (testTypeSwitch2) ignored due to issue #1604 |
_demo/gogen/package/package.go
Outdated
There was a problem hiding this comment.
@xgopilot move to _demo/gogen/package, with this sturcture the test_demo.sh will correct process this test! and rename to package.go!
There was a problem hiding this comment.
Completed: File moved and renamed ✅
- Created directory
_demo/gogen/package/ - Moved and renamed file to
_demo/gogen/package/package.go - Fixed compilation error (commented out call to
testTypeSwitch2()) - Committed and pushed changes
Changes pushed: Created PR #192 in your fork to merge the changes to this PR branch.
The test file is now at _demo/gogen/package/package.go which will be correctly processed by test_demo.sh.
065dd0e to
8a40fe2
Compare
Add a comprehensive test suite for gogen package functionality, covering 29 different test cases including: - Package import and redefinition handling - Built-in type methods and conversions - Type declarations and method definitions - Interface assignments and type switches - Channel operations and concurrency primitives This test file was converted from gogen's package_test.go to demonstrate llgo's compatibility with gogen package manipulation. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
8a40fe2 to
f9ea129
Compare
Merged PR #1598 into this branch ✅Successfully merged changes from PR #1598 into this PR. Changes merged:
Commit: This PR now includes both the gogen package_test suite and the embedded unexported methods fix. |
…hods This merges the fix for generating valid function pointers for embedded type's unexported methods. - Fix ssa/abitype.go: remove skipfn logic that was setting Ifn_ to nil - Add regression tests for embedunexport-1598 - Update out.ll test files Original PR: goplus#1598 Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
|
@xgopilot resolve conflict! |
Conflicts Resolved ✅Successfully merged What was done:
Commit: The PR is now up-to-date with |
Resolve conflicts in out.ll files by regenerating them via gentests. This merge brings in all recent changes from main. Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
- Add TargetMachine and DataLayout methods to Program - Set data layout and target triple on Module creation - Run memcpyopt pass after IR generation (skip runtime packages) This optimization converts consecutive load/store operations on aggregate types to more efficient memcpy/memmove calls. Fixes goplus#1605
- Add TargetMachine and DataLayout methods to Program - Set data layout and target triple on Module creation - Run memcpyopt pass after IR generation (skip runtime packages) This optimization converts consecutive load/store operations on aggregate types to more efficient memcpy/memmove calls. Fixes goplus#1605
- Add TargetMachine and DataLayout methods to Program - Set data layout and target triple on Module creation - Run memcpyopt pass after IR generation (skip runtime packages) This optimization converts consecutive load/store operations on aggregate types to more efficient memcpy/memmove calls. Fixes goplus#1605
- Add TargetMachine and DataLayout methods to Program - Set data layout and target triple on Module creation - Run memcpyopt pass after IR generation (skip runtime packages) This optimization converts consecutive load/store operations on aggregate types to more efficient memcpy/memmove calls. Fixes goplus#1605
- Add TargetMachine and DataLayout methods to Program - Set data layout and target triple on Module creation - Run memcpyopt pass after IR generation (skip runtime packages) This optimization converts consecutive load/store operations on aggregate types to more efficient memcpy/memmove calls. Fixes goplus#1605
- Add targetInfo() to return TargetData and TargetMachine - Add TargetMachine() and DataLayout() methods to Program - Set data layout and target triple before running LLVM passes - Run memcpyopt pass after IR generation to convert load/store to memcpy This replaces the manual optimization in cabi with LLVM's built-in memcpyopt pass, which handles more cases and is more robust. Fixes goplus#1605
- Add targetInfo() to return TargetData and TargetMachine - Add TargetMachine() and DataLayout() methods to Program - Set data layout and target triple before running LLVM passes - Run memcpyopt pass after IR generation to convert load/store to memcpy This replaces the manual optimization in cabi with LLVM's built-in memcpyopt pass, which handles more cases and is more robust. Fixes goplus#1605
- Add targetInfo() to return TargetData and TargetMachine - Add TargetMachine() and DataLayout() methods to Program - Set data layout and target triple before running LLVM passes - Run memcpyopt pass after IR generation to convert load/store to memcpy This replaces the manual optimization in cabi with LLVM's built-in memcpyopt pass, which handles more cases and is more robust. Fixes goplus#1605
- Add targetInfo() to return TargetData and TargetMachine - Add TargetMachine() and DataLayout() methods to Program - Set data layout and target triple before running LLVM passes - Run memcpyopt pass after IR generation to convert load/store to memcpy This replaces the manual optimization in cabi with LLVM's built-in memcpyopt pass, which handles more cases and is more robust. Fixes goplus#1605
- Add targetInfo() to return TargetData and TargetMachine - Add TargetMachine() and DataLayout() methods to Program - Set data layout and target triple before running LLVM passes - Run memcpyopt pass after IR generation to convert load/store to memcpy This replaces the manual optimization in cabi with LLVM's built-in memcpyopt pass, which handles more cases and is more robust. Fixes goplus#1605
Summary
Add a comprehensive test suite demonstrating llgo's compatibility with the gogen package manipulation API.
Changes
_demo/gogen/package_test.gowith 29 test cases covering:Test Coverage
This test file was converted from gogen's
package_test.goto verify that llgo can successfully compile code that uses gogen's advanced code generation features.Test Plan
All 29 tests should pass, demonstrating llgo's ability to work with gogen's type system and code generation APIs.
🤖 Generated with Claude Code