github.com/web-platform-tests/wpt.fyi@v0.0.0-20240530210107-70cf978996f1/webdriver/dev-data.js (about) 1 /** 2 * Copyright 2019 The WPT Dashboard Project. All rights reserved. 3 * Use of this source code is governed by a BSD-style license that can be 4 * found in the LICENSE file. 5 */ 6 7 const log = require('debug')('wpt.fyi'); 8 const logDevData = require('debug')('wpt.fyi:dev_data'); 9 const { spawn } = require('child_process'); 10 const process = require('process'); 11 const { DevAppserver } = require('./appserver.js'); 12 13 /** 14 * @param {DevAppserver} server 15 */ 16 function populate(server) { 17 return new Promise(resolve => { 18 const args = [ 19 'run', 20 '../util/populate_dev_data.go', 21 `--project=${server.config.project}`, 22 `--datastore_host=127.0.0.1:${server.config.gcdPort}`, 23 `--local_host=localhost:${server.config.port}`, 24 `--remote_runs=false`, 25 `--static_runs=true`, 26 ]; 27 log('Running go ' + args.join(' ')); 28 const child = spawn('go', args); 29 process.on('exit', () => { 30 log('killing dev_data subprocess...'); 31 child.kill(); 32 }); 33 child.stderr.on('data', buffer => { logDevData(buffer.toString()); }); 34 child.on('exit', exitCode => { 35 log(`populate_dev_data.go exited with code ${exitCode}`); 36 resolve(); 37 if (exitCode) { 38 throw `dev_data child process exited with ${exitCode}`; 39 } 40 }); 41 }); 42 } 43 exports.populate = populate;