Browse code

Merge "meta-config: Fix consecutive same sections"

Jenkins authored on 2016/11/29 08:43:11
Showing 2 changed files
... ...
@@ -40,12 +40,10 @@ function get_meta_section {
40 40
     $CONFIG_AWK_CMD -v matchgroup=$matchgroup -v configfile=$configfile '
41 41
         BEGIN { group = "" }
42 42
         /^\[\[.+\|.*\]\]/ {
43
-            if (group == "") {
44
-                gsub("[][]", "", $1);
45
-                split($1, a, "|");
46
-                if (a[1] == matchgroup && a[2] == configfile) {
47
-                    group=a[1]
48
-                }
43
+            gsub("[][]", "", $1);
44
+            split($1, a, "|");
45
+            if (a[1] == matchgroup && a[2] == configfile) {
46
+                group=a[1]
49 47
             } else {
50 48
                 group=""
51 49
             }
... ...
@@ -125,6 +125,14 @@ foo=bar
125 125
 [[test10|does-not-exist-dir/test.conf]]
126 126
 foo=bar
127 127
 
128
+[[test11|test-same.conf]]
129
+[DEFAULT]
130
+foo=bar
131
+
132
+[[test11|test-same.conf]]
133
+[some]
134
+random=config
135
+
128 136
 [[test-multi-sections|test-multi-sections.conf]]
129 137
 [sec-1]
130 138
 cfg_item1 = abcd
... ...
@@ -147,6 +155,9 @@ cfg_item1 = abcd
147 147
 cfg_item2 = efgh
148 148
 cfg_item2 = \${FOO_BAR_BAZ}
149 149
 
150
+[[test11|test-same.conf]]
151
+[another]
152
+non = sense
150 153
 EOF
151 154
 
152 155
 echo -n "get_meta_section_files: test0 doesn't exist: "
... ...
@@ -385,8 +396,24 @@ EXPECT_VAL=255
385 385
 check_result "$VAL" "$EXPECT_VAL"
386 386
 set -e
387 387
 
388
+echo -n "merge_config_file test11 same section: "
389
+rm -f test-same.conf
390
+merge_config_group test.conf test11
391
+VAL=$(cat test-same.conf)
392
+EXPECT_VAL='
393
+[DEFAULT]
394
+foo = bar
395
+
396
+[some]
397
+random = config
398
+
399
+[another]
400
+non = sense'
401
+check_result "$VAL" "$EXPECT_VAL"
402
+
403
+
388 404
 rm -f test.conf test1c.conf test2a.conf \
389 405
     test-space.conf test-equals.conf test-strip.conf \
390 406
     test-colon.conf test-env.conf test-multiline.conf \
391
-    test-multi-sections.conf
407
+    test-multi-sections.conf test-same.conf
392 408
 rm -rf test-etc