This is an automated email from the ASF dual-hosted git repository.

sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit 972e5bcfc6689b2cd0528522746b45bec497aadc
Author: Szymon Janc <[email protected]>
AuthorDate: Tue Oct 20 15:55:31 2026 +0200

    newt/toolchain: Add unit test for compiler.c.flags
    
    Verify that compiler.c.flags are appended to C flags, that a C-only
    flag is dropped when the common flags already contain one with the
    same base, and that an option with a separate argument stays together
    with it.
    
    Assisted-by: Claude:claude-opus-5-5
---
 newt/toolchain/flags_test.go | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/newt/toolchain/flags_test.go b/newt/toolchain/flags_test.go
index fb25da16..88d7a480 100644
--- a/newt/toolchain/flags_test.go
+++ b/newt/toolchain/flags_test.go
@@ -109,3 +109,30 @@ func TestCflagsStringsPairs(t *testing.T) {
                t.Errorf("unexpected flags:\nexpected %q\ngot      %q", exp, 
got)
        }
 }
+
+func TestCcflagsStrings(t *testing.T) {
+       tests := []struct {
+               cflags  []string
+               ccflags []string
+               exp     []string
+       }{
+               {[]string{"-Wall"}, []string{"-std=c11"},
+                       []string{"-Wall", "-std=c11"}},
+               {[]string{"-Wall", "-std=gnu99"}, []string{"-std=c11"},
+                       []string{"-Wall", "-std=gnu99"}},
+               {[]string{"-Wall"}, []string{}, []string{"-Wall"}},
+               {[]string{"-Wall"}, []string{"-include", "a.h", "-std=c11"},
+                       []string{"-Wall", "-std=c11", "-include", "a.h"}},
+       }
+
+       for _, tt := range tests {
+               c := &Compiler{}
+               c.info.Cflags = tt.cflags
+               c.info.CCflags = tt.ccflags
+               got := c.ccflagsStrings()
+               if !slices.Equal(got, tt.exp) {
+                       t.Errorf("ccflagsStrings() with cflags %q ccflags %q = 
%q, "+
+                               "expected %q", tt.cflags, tt.ccflags, got, 
tt.exp)
+               }
+       }
+}

Reply via email to