1// Copyright 2021 the V8 project authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5/** 6 * @fileoverview Test the script building the DB. 7 */ 8 9'use strict'; 10 11const assert = require('assert'); 12const { execSync } = require("child_process"); 13const fs = require('fs'); 14const path = require('path'); 15const tempy = require('tempy'); 16 17function buildDb(inputDir, corpusName, outputDir) { 18 execSync( 19 `node build_db.js -i ${inputDir} -o ${outputDir} ${corpusName}`, 20 {stdio: ['pipe']}); 21} 22 23describe('DB tests', () => { 24 // Test feeds an expression that does not apply. 25 it('omits erroneous expressions', () => { 26 const outPath = tempy.directory(); 27 buildDb('test_data/db', 'this', outPath); 28 const indexFile = path.join(outPath, 'index.json'); 29 const indexJSON = JSON.parse(fs.readFileSync(indexFile), 'utf-8'); 30 assert.deepEqual( 31 indexJSON, {"statements": [], "superStatements": [], "all": []}); 32 }); 33}); 34