Quellcode durchsuchen

builder/parser: fix handling of empty strings as the only argument.

Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
Erik Hollensbe vor 11 Jahren
Ursprung
Commit
6b322ad2d3

+ 4 - 2
builder/parser/parser.go

@@ -81,8 +81,10 @@ func parseLine(line string) (string, *Node, error) {
 		return "", nil, err
 	}
 
-	node.Next = sexp
-	node.Attributes = attrs
+	if sexp.Value != "" || sexp.Next != nil || sexp.Children != nil {
+		node.Next = sexp
+		node.Attributes = attrs
+	}
 
 	return "", node, nil
 }

+ 4 - 1
builder/parser/parser_test.go

@@ -1,6 +1,7 @@
 package parser
 
 import (
+	"fmt"
 	"io/ioutil"
 	"os"
 	"path/filepath"
@@ -69,7 +70,9 @@ func TestTestData(t *testing.T) {
 			t.Fatalf("Error reading %s's result file: %s", dir.Name(), err.Error())
 		}
 
-		if ast.Dump() != string(content) {
+		if ast.Dump()+"\n" != string(content) {
+			fmt.Fprintln(os.Stderr, ast.Dump())
+			fmt.Fprintln(os.Stderr, string(content))
 			t.Fatalf("%s: AST dump of dockerfile does not match result", dir.Name())
 		}
 

+ 1 - 1
builder/parser/testfiles/brimstone-docker-consul/result

@@ -1,5 +1,5 @@
 (from "brimstone/ubuntu:14.04")
-(cmd "")
+(cmd)
 (entrypoint "/usr/bin/consul" "agent" "-server" "-data-dir=/consul" "-client=0.0.0.0" "-ui-dir=/webui")
 (expose "8500" "8600" "8400" "8301" "8302")
 (run "apt-get update && apt-get install -y unzip wget && apt-get clean && rm -rf /var/lib/apt/lists")