@@ -60,18 +60,32 @@ func TestProcessorFrontendOK(t *testing.T) {
6060
6161type fakeAcc struct {
6262 * testing.B
63+ benchmarkingConsumer * s.Consumer
64+ }
65+
66+ var testSourcemapInfo = struct {
67+ name , file string
68+ }{
69+ name : "http://localhost:8000/test/e2e/general-usecase/app.e2e-bundle.min.js" ,
70+ file : "app.e2e-bundle.min.js.map" ,
71+ }
72+
73+ func (ac * fakeAcc ) PreFetch () error {
74+ var err error
75+ ac .benchmarkingConsumer , err = ac .Fetch (sourcemap.Id {ServiceName : testSourcemapInfo .name })
76+ return err
6377}
6478
6579func (ac * fakeAcc ) Fetch (smapId sourcemap.Id ) (* s.Consumer , error ) {
66- if ac .B != nil {
67- ac .B .StopTimer ()
68- defer ac .B .StartTimer ()
69- }
7080 file := "bundle.js.map"
71- if smapId .Path == "http://localhost:8000/test/e2e/general-usecase/app.e2e-bundle.min.js" {
72- file = "app.e2e-bundle.min.js.map"
81+ if smapId .Path == testSourcemapInfo .name {
82+ // only not nil if PreFetch called
83+ // PreFetch only called from benchmarks, optionally
84+ if ac .B != nil && ac .benchmarkingConsumer != nil {
85+ return ac .benchmarkingConsumer , nil
86+ }
87+ file = testSourcemapInfo .file
7388 }
74-
7589 current , _ := os .Getwd ()
7690 path := filepath .Join (current , "../../../tests/data/valid/sourcemap/" , file )
7791 fileBytes , err := ioutil .ReadFile (path )
@@ -88,7 +102,9 @@ func BenchmarkBackendProcessor(b *testing.B) {
88102}
89103
90104func BenchmarkFrontendProcessor (b * testing.B ) {
91- mapper := sourcemap.SmapMapper {Accessor : & fakeAcc {B : b }}
105+ accessor := & fakeAcc {B : b }
106+ accessor .PreFetch ()
107+ mapper := sourcemap.SmapMapper {Accessor : accessor }
92108 conf := config.Config {
93109 SmapMapper : & mapper ,
94110 LibraryPattern : regexp .MustCompile ("^test/e2e|~" ),
0 commit comments