|  | // Copyright (c) 2018, Compiler Explorer Authors | 
|  | // All rights reserved. | 
|  | // | 
|  | // Redistribution and use in source and binary forms, with or without | 
|  | // modification, are permitted provided that the following conditions are met: | 
|  | // | 
|  | //     * Redistributions of source code must retain the above copyright notice, | 
|  | //       this list of conditions and the following disclaimer. | 
|  | //     * Redistributions in binary form must reproduce the above copyright | 
|  | //       notice, this list of conditions and the following disclaimer in the | 
|  | //       documentation and/or other materials provided with the distribution. | 
|  | // | 
|  | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 
|  | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 
|  | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 
|  | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | 
|  | // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 
|  | // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 
|  | // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 
|  | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 
|  | // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 
|  | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 
|  | // POSSIBILITY OF SUCH DAMAGE. | 
|  |  | 
|  | const chai = require('chai'); | 
|  | const chaiAsPromised = require("chai-as-promised"); | 
|  | const BaseCompiler = require('../lib/base-compiler'); | 
|  | const CompilationEnvironment = require('../lib/compilation-env'); | 
|  |  | 
|  | chai.use(chaiAsPromised); | 
|  | const should = chai.should(); | 
|  |  | 
|  | const props = (key, deflt) => deflt; | 
|  |  | 
|  | describe('Basic compiler invariants', function () { | 
|  | const ce = new CompilationEnvironment(props); | 
|  | const info = { | 
|  | exe: null, | 
|  | remote: true, | 
|  | lang: "c++" | 
|  | }; | 
|  |  | 
|  | ce.compilerPropsL = () => ""; | 
|  |  | 
|  | const compiler = new BaseCompiler(info, ce); | 
|  |  | 
|  | it('should recognize when optOutput has been request', () => { | 
|  | compiler.optOutputRequested(["please", "recognize", "-fsave-optimization-record"]).should.equal(true); | 
|  | compiler.optOutputRequested(["please", "don't", "recognize"]).should.equal(false); | 
|  | }); | 
|  | // Overkill test, but now we're safer! | 
|  | it('should recognize cfg compilers', () => { | 
|  | compiler.isCfgCompiler("clang version 5.0.0 (https://github.com/asutton/clang.git 449c8c3e91355a3b2b6761e11d9fb5d3c125b791) (https://github.com/llvm-mirror/llvm.git 40b1e969f9cb2a0c697e247435193fb006ef1311)").should.equal(true); | 
|  | compiler.isCfgCompiler("clang version 4.0.0 (tags/RELEASE_400/final 299826)").should.equal(true); | 
|  | compiler.isCfgCompiler("clang version 7.0.0 (trunk 325868)").should.equal(true); | 
|  | compiler.isCfgCompiler("clang version 3.3 (tags/RELEASE_33/final)").should.equal(true); | 
|  | compiler.isCfgCompiler("clang version 6.0.0 (tags/RELEASE_600/final 327031) (llvm/tags/RELEASE_600/final 327028)").should.equal(true); | 
|  |  | 
|  | compiler.isCfgCompiler("g++ (GCC-Explorer-Build) 4.9.4").should.equal(true); | 
|  | compiler.isCfgCompiler("g++ (GCC-Explorer-Build) 8.0.1 20180223 (experimental)").should.equal(true); | 
|  | compiler.isCfgCompiler("g++ (GCC-Explorer-Build) 8.0.1 20180223 (experimental)").should.equal(true); | 
|  | compiler.isCfgCompiler("g++ (GCC) 4.1.2").should.equal(true); | 
|  |  | 
|  | compiler.isCfgCompiler("fake-for-test (Based on g++)").should.equal(false); | 
|  |  | 
|  | compiler.isCfgCompiler("gdc (crosstool-NG 203be35 - 20160205-2.066.1-e95a735b97) 5.2.0").should.equal(true); | 
|  | compiler.isCfgCompiler("gdc (crosstool-NG hg+unknown-20131212.080758 - 20140430-2.064.2-404a037d26) 4.8.2").should.equal(true); | 
|  | compiler.isCfgCompiler("gdc (crosstool-NG crosstool-ng-1.20.0-232-gc746732 - 20150830-2.066.1-d0dd4a83de) 4.9.3").should.equal(true); | 
|  |  | 
|  | compiler.isCfgCompiler("fake-for-test (Based on gdc)").should.equal(false); | 
|  | }); | 
|  | it('should allow comments next to includes (Bug #874)', () => { | 
|  | let text = "#include <cmath> // std::(sin, cos, ...)"; | 
|  | should.equal(compiler.checkSource(text), null); | 
|  | const badSource = compiler.checkSource("#include </dev/null..> //Muehehehe"); | 
|  | should.exist(badSource); | 
|  | badSource.should.equal("<stdin>:1:1: no absolute or relative includes please") | 
|  | }); | 
|  | }); |