Переглянути джерело

apply filters to -proto output format (#393)

* make filters applied to -proto output

* update comments

* address comments

* reassign flags in TestParse

* update TestParse to address comments

* use original names for options in TestParse
Margaret Nolan 6 роки тому
джерело
коміт
3e1e08e68e
No account linked to committer's email address
2 змінених файлів з 10 додано та 24 видалено
  1. 3
    14
      internal/driver/driver.go
  2. 7
    10
      internal/driver/driver_test.go

+ 3
- 14
internal/driver/driver.go Переглянути файл

@@ -152,7 +152,7 @@ func generateReport(p *profile.Profile, cmd []string, vars variables, o *plugin.
152 152
 }
153 153
 
154 154
 func applyCommandOverrides(cmd string, outputFormat int, v variables) variables {
155
-	trim, tagfilter, filter := v["trim"].boolValue(), true, true
155
+	trim := v["trim"].boolValue()
156 156
 
157 157
 	switch cmd {
158 158
 	case "callgrind", "kcachegrind":
@@ -162,7 +162,7 @@ func applyCommandOverrides(cmd string, outputFormat int, v variables) variables
162 162
 		trim = false
163 163
 		v.set("addressnoinlines", "t")
164 164
 	case "peek":
165
-		trim, tagfilter, filter = false, false, false
165
+		trim = false
166 166
 	case "list":
167 167
 		v.set("nodecount", "0")
168 168
 		v.set("lines", "t")
@@ -177,7 +177,7 @@ func applyCommandOverrides(cmd string, outputFormat int, v variables) variables
177 177
 	}
178 178
 
179 179
 	if outputFormat == report.Proto || outputFormat == report.Raw {
180
-		trim, tagfilter, filter = false, false, false
180
+		trim = false
181 181
 		v.set("addresses", "t")
182 182
 	}
183 183
 
@@ -186,17 +186,6 @@ func applyCommandOverrides(cmd string, outputFormat int, v variables) variables
186 186
 		v.set("nodefraction", "0")
187 187
 		v.set("edgefraction", "0")
188 188
 	}
189
-	if !tagfilter {
190
-		v.set("tagfocus", "")
191
-		v.set("tagignore", "")
192
-	}
193
-	if !filter {
194
-		v.set("focus", "")
195
-		v.set("ignore", "")
196
-		v.set("hide", "")
197
-		v.set("show", "")
198
-		v.set("show_from", "")
199
-	}
200 189
 	return v
201 190
 }
202 191
 

+ 7
- 10
internal/driver/driver_test.go Переглянути файл

@@ -109,9 +109,6 @@ func TestParse(t *testing.T) {
109 109
 
110 110
 			flags := strings.Split(tc.flags, ",")
111 111
 
112
-			// Skip the output format in the first flag, to output to a proto
113
-			addFlags(&f, flags[1:])
114
-
115 112
 			// Encode profile into a protobuf and decode it again.
116 113
 			protoTempFile, err := ioutil.TempFile("", "profile_proto")
117 114
 			if err != nil {
@@ -124,6 +121,7 @@ func TestParse(t *testing.T) {
124 121
 			if flags[0] == "topproto" {
125 122
 				f.bools["proto"] = false
126 123
 				f.bools["topproto"] = true
124
+				f.bools["addresses"] = true
127 125
 			}
128 126
 
129 127
 			// First pprof invocation to save the profile into a profile.proto.
@@ -145,23 +143,22 @@ func TestParse(t *testing.T) {
145 143
 			}
146 144
 			defer os.Remove(outputTempFile.Name())
147 145
 			defer outputTempFile.Close()
146
+
147
+			f = baseFlags()
148 148
 			f.strings["output"] = outputTempFile.Name()
149 149
 			f.args = []string{protoTempFile.Name()}
150 150
 
151
-			var solution string
151
+			delete(f.bools, "proto")
152
+			addFlags(&f, flags)
153
+			solution := solutionFilename(tc.source, &f)
152 154
 			// Apply the flags for the second pprof run, and identify name of
153 155
 			// the file containing expected results
154 156
 			if flags[0] == "topproto" {
157
+				addFlags(&f, flags)
155 158
 				solution = solutionFilename(tc.source, &f)
156 159
 				delete(f.bools, "topproto")
157 160
 				f.bools["text"] = true
158
-			} else {
159
-				delete(f.bools, "proto")
160
-				addFlags(&f, flags[:1])
161
-				solution = solutionFilename(tc.source, &f)
162 161
 			}
163
-			// The add_comment flag is not idempotent so only apply it on the first run.
164
-			delete(f.strings, "add_comment")
165 162
 
166 163
 			// Second pprof invocation to read the profile from profile.proto
167 164
 			// and generate a report.