You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by mg...@apache.org on 2024/09/06 13:13:50 UTC

(mynewt-newt) branch master updated (b2468d97 -> 15c4ac6f)

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

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


    from b2468d97 newt: Extend link tables filter
     new 4e78dbe8 Report ambiguous syscfg configuration
     new 15c4ac6f ci: Add ambiguous config test

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../ambiguous_fail}/pkg.yml                        |  3 +-
 .github/targets/ambiguous_fail/syscfg.yml          | 10 +++++++
 .../ambiguous_fail}/target.yml                     |  2 +-
 .../ambiguous_success}/pkg.yml                     |  3 +-
 .github/targets/ambiguous_success/syscfg.yml       | 10 +++++++
 .../ambiguous_success}/target.yml                  |  2 +-
 .../{test_sysinit.yml => test_ambiguous_cfg.yml}   | 35 ++++++++++++----------
 newt/cli/target_cmds.go                            |  4 ++-
 newt/syscfg/syscfg.go                              |  4 ++-
 newt/ycfg/ycfg.go                                  | 21 +++++++++++--
 10 files changed, 68 insertions(+), 26 deletions(-)
 copy .github/{newt_dump/proj/targets/btshell-nrf52840pdk => targets/ambiguous_fail}/pkg.yml (60%)
 create mode 100644 .github/targets/ambiguous_fail/syscfg.yml
 copy .github/{newt_dump/proj/targets/btshell-nrf52840pdk => targets/ambiguous_fail}/target.yml (58%)
 copy .github/{newt_dump/proj/targets/btshell-nrf52840pdk => targets/ambiguous_success}/pkg.yml (60%)
 create mode 100644 .github/targets/ambiguous_success/syscfg.yml
 copy .github/{newt_dump/proj/targets/btshell-nrf52840pdk => targets/ambiguous_success}/target.yml (58%)
 copy .github/workflows/{test_sysinit.yml => test_ambiguous_cfg.yml} (65%)


(mynewt-newt) 01/02: Report ambiguous syscfg configuration

Posted by mg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 4e78dbe8b3dfd326feb76c61ca7d32954e633c58
Author: Michal Gorecki <mi...@codecoup.pl>
AuthorDate: Mon Aug 19 10:03:19 2024 +0200

    Report ambiguous syscfg configuration
    
    This addresses: https://github.com/apache/mynewt-newt/issues/565
---
 newt/cli/target_cmds.go |  4 +++-
 newt/syscfg/syscfg.go   |  4 +++-
 newt/ycfg/ycfg.go       | 21 ++++++++++++++++++---
 3 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/newt/cli/target_cmds.go b/newt/cli/target_cmds.go
index b3a13e54..75ed4e06 100644
--- a/newt/cli/target_cmds.go
+++ b/newt/cli/target_cmds.go
@@ -97,7 +97,9 @@ func pkgVarSliceString(pack *pkg.LocalPackage, key string) string {
 func amendSysCfg(value string, t *target.Target) error {
 	// Get the current syscfg.vals name-value pairs
 	sysVals, err := t.Package().SyscfgY.GetValStringMapString("syscfg.vals", nil)
-	util.OneTimeWarningError(err)
+	if err != nil {
+		return err
+	}
 
 	// Convert the input syscfg into name-value pairs
 	amendSysVals, err := syscfg.KeyValueFromStr(value)
diff --git a/newt/syscfg/syscfg.go b/newt/syscfg/syscfg.go
index e7f62ff0..886699cc 100644
--- a/newt/syscfg/syscfg.go
+++ b/newt/syscfg/syscfg.go
@@ -708,7 +708,9 @@ func (cfg *Cfg) readValsOnce(lpkg *pkg.LocalPackage,
 	lsettings := cfg.settingsForLpkg(lpkg, settings)
 
 	values, err := yc.GetValStringMap("syscfg.vals", lsettings)
-	util.OneTimeWarningError(err)
+	if err != nil {
+		return err
+	}
 
 	for k, v := range values {
 		switch v.(type) {
diff --git a/newt/ycfg/ycfg.go b/newt/ycfg/ycfg.go
index 4ae8f7ca..08d33477 100644
--- a/newt/ycfg/ycfg.go
+++ b/newt/ycfg/ycfg.go
@@ -469,7 +469,13 @@ func (yc *YCfg) GetStringMap(
 				Expr:  mapEntry.Expr,
 			}
 
-			// XXX: Report collisions?
+			if _, exists := result[k]; exists {
+				if (entry.Value != result[k].Value) && (result[k].Expr != nil) {
+					return nil, fmt.Errorf("Setting %s collision - two conditions true:\n[%s, %s]\n"+
+						"Conflicting file: %s",
+						k, entry.Expr.String(), result[k].Expr.String(), yc.name)
+				}
+			}
 			result[k] = entry
 		}
 	}
@@ -607,7 +613,13 @@ func (yc *YCfg) GetStringMapString(key string,
 				Expr:  mapEntry.Expr,
 			}
 
-			// XXX: Report collisions?
+			if _, exists := result[k]; exists {
+				if (entry.Value != result[k].Value) && (result[k].Expr != nil) {
+					return nil, fmt.Errorf("Setting %s collision - two conditions true:\n[%s, %s]\n"+
+						"Conflicting file: %s",
+						k, entry.Expr.String(), result[k].Expr.String(), yc.name)
+				}
+			}
 			result[k] = entry
 		}
 	}
@@ -623,6 +635,9 @@ func (yc *YCfg) GetValStringMapString(key string,
 	settings *cfgv.Settings) (map[string]string, error) {
 
 	entryMap, getErr := yc.GetStringMapString(key, settings)
+	if getErr != nil {
+		return nil, getErr
+	}
 
 	valMap := make(map[string]string, len(entryMap))
 	for k, v := range entryMap {
@@ -631,7 +646,7 @@ func (yc *YCfg) GetValStringMapString(key string,
 		}
 	}
 
-	return valMap, getErr
+	return valMap, nil
 }
 
 // FullName calculates a node's name with the following form:


(mynewt-newt) 02/02: ci: Add ambiguous config test

Posted by mg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 15c4ac6fd53ece00a7d302f74b01db4d8a231795
Author: Michal Gorecki <mi...@codecoup.pl>
AuthorDate: Fri Aug 30 13:43:25 2024 +0200

    ci: Add ambiguous config test
---
 .github/targets/ambiguous_fail/pkg.yml       |  5 +++
 .github/targets/ambiguous_fail/syscfg.yml    | 10 +++++
 .github/targets/ambiguous_fail/target.yml    |  3 ++
 .github/targets/ambiguous_success/pkg.yml    |  5 +++
 .github/targets/ambiguous_success/syscfg.yml | 10 +++++
 .github/targets/ambiguous_success/target.yml |  3 ++
 .github/workflows/test_ambiguous_cfg.yml     | 66 ++++++++++++++++++++++++++++
 7 files changed, 102 insertions(+)

diff --git a/.github/targets/ambiguous_fail/pkg.yml b/.github/targets/ambiguous_fail/pkg.yml
new file mode 100644
index 00000000..dba5fd24
--- /dev/null
+++ b/.github/targets/ambiguous_fail/pkg.yml
@@ -0,0 +1,5 @@
+pkg.name: "targets/ambiguous_fail"
+pkg.type: target
+pkg.description: 
+pkg.author: 
+pkg.homepage: 
diff --git a/.github/targets/ambiguous_fail/syscfg.yml b/.github/targets/ambiguous_fail/syscfg.yml
new file mode 100644
index 00000000..0ff26b6a
--- /dev/null
+++ b/.github/targets/ambiguous_fail/syscfg.yml
@@ -0,0 +1,10 @@
+syscfg.vals:
+    SHELL_PROMPT_MODULE: 1
+    SHELL_TASK: 1
+
+syscfg.vals.SHELL_PROMPT_MODULE:
+    CONSOLE_IMPLEMENTATION: stub
+
+# This should fail
+syscfg.vals.SHELL_TASK:
+    CONSOLE_IMPLEMENTATION: full
diff --git a/.github/targets/ambiguous_fail/target.yml b/.github/targets/ambiguous_fail/target.yml
new file mode 100644
index 00000000..2d850208
--- /dev/null
+++ b/.github/targets/ambiguous_fail/target.yml
@@ -0,0 +1,3 @@
+target.app: "@apache-mynewt-nimble/apps/btshell"
+target.bsp: "@apache-mynewt-core/hw/bsp/nordic_pca10056"
+target.build_profile: optimized
diff --git a/.github/targets/ambiguous_success/pkg.yml b/.github/targets/ambiguous_success/pkg.yml
new file mode 100644
index 00000000..f4f8c20d
--- /dev/null
+++ b/.github/targets/ambiguous_success/pkg.yml
@@ -0,0 +1,5 @@
+pkg.name: "targets/ambiguous_success"
+pkg.type: target
+pkg.description: 
+pkg.author: 
+pkg.homepage: 
diff --git a/.github/targets/ambiguous_success/syscfg.yml b/.github/targets/ambiguous_success/syscfg.yml
new file mode 100644
index 00000000..c9935d56
--- /dev/null
+++ b/.github/targets/ambiguous_success/syscfg.yml
@@ -0,0 +1,10 @@
+syscfg.vals:
+    SHELL_PROMPT_MODULE: 1
+    SHELL_TASK: 1
+
+syscfg.vals.SHELL_PROMPT_MODULE:
+    CONSOLE_IMPLEMENTATION: stub
+
+# This should not fail as it sets the same value as previous conditional config
+syscfg.vals.SHELL_TASK:
+    CONSOLE_IMPLEMENTATION: stub
diff --git a/.github/targets/ambiguous_success/target.yml b/.github/targets/ambiguous_success/target.yml
new file mode 100644
index 00000000..2d850208
--- /dev/null
+++ b/.github/targets/ambiguous_success/target.yml
@@ -0,0 +1,3 @@
+target.app: "@apache-mynewt-nimble/apps/btshell"
+target.bsp: "@apache-mynewt-core/hw/bsp/nordic_pca10056"
+target.build_profile: optimized
diff --git a/.github/workflows/test_ambiguous_cfg.yml b/.github/workflows/test_ambiguous_cfg.yml
new file mode 100644
index 00000000..c2d4f505
--- /dev/null
+++ b/.github/workflows/test_ambiguous_cfg.yml
@@ -0,0 +1,66 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+name: Test ambiguous config
+
+on: [push, pull_request]
+
+jobs:
+  test_ambiguous_cfg:
+    name: other
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [ubuntu-latest, windows-latest, macos-latest]
+    runs-on: ${{ matrix.os }}
+    steps:
+      - uses: actions/checkout@v3
+      - uses: actions/setup-go@v3
+        with:
+          go-version: 'stable'
+      - uses: carlosperate/arm-none-eabi-gcc-action@48db4484a55750df7a0ccca63347fcdea6534d78
+        with:
+          release: '12.2.Rel1'
+      - name: Install Dependencies
+        if: matrix.os == 'ubuntu-latest'
+        run: |
+          sudo apt-get update
+          sudo apt-get install -y gcc-multilib
+      - name: Build newt
+        working-directory: newt
+        shell: bash
+        run: |
+          go version
+          go build
+          echo  ${GITHUB_WORKSPACE}/newt >> $GITHUB_PATH
+      - name: Test ambiguous cfg (success)
+        shell: bash
+        run: |
+          newt new project
+          cp -r .github/targets/ambiguous_success project/targets
+          cd project/
+          newt upgrade -v
+          newt build ambiguous_success
+      - name: Test ambiguous cfg (fail)
+        shell: bash
+        run: |
+          cp -r .github/targets/ambiguous_fail project/targets
+          cd project/
+          ! newt build ambiguous_fail &> tmp.txt
+          grep "Error: Setting CONSOLE_IMPLEMENTATION collision - two conditions true:" tmp.txt -q