blob: 8ada61aef1df2442a1ad299e1c737d0008d9d2b6 [file] [log] [blame] [raw]
RabsRinconfc752082018-01-01 16:44:04 +01001// Copyright (c) 2012-2018, Matt Godbolt
Matt Godboltbc5848f2016-11-16 21:52:05 -06002// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are met:
6//
7// * Redistributions of source code must retain the above copyright notice,
8// this list of conditions and the following disclaimer.
9// * Redistributions in binary form must reproduce the above copyright
10// notice, this list of conditions and the following disclaimer in the
11// documentation and/or other materials provided with the distribution.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
17// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ,
22// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23// POSSIBILITY OF SUCH DAMAGE.
24
25var should = require('chai').should();
26var CompilationEnvironment = require('../lib/compilation-env').CompilationEnvironment;
27
28var props = function (key, deflt) {
29 switch (key) {
30 case 'optionsWhitelistRe':
31 return '.*';
32 case 'optionsBlacklistRe':
33 return '^(-W[alp],)?((-wrapper|-fplugin.*|-specs|-load|-plugin|(@.*)|-I|-i)(=.*)?|--)$';
34 }
35 return deflt;
36};
37
38describe('Compilation environment', function () {
39 var ce = new CompilationEnvironment(props);
40 it('Should cache', function () {
41 should.not.exist(ce.cacheGet('foo'));
42 ce.cachePut('foo', 'bar');
43 ce.cacheGet('foo').should.equal('bar');
44 should.not.exist(ce.cacheGet('baz'));
45 });
46 it('Should filter bad options', function () {
47 ce.findBadOptions(['-O3', '-flto']).should.be.empty;
48 ce.findBadOptions(['-O3', '-plugin']).should.eql(['-plugin']);
49 });
Matt Godbolt89efa6f2017-12-11 07:41:23 -060050});