Sha256: 27cbeade1fdf2873f8c0d543ac82b50c09f233926a60a2218dca652935299e0c

Contents?: true

Size: 1.94 KB

Versions: 13

Compression:

Stored size: 1.94 KB

Contents

require 'gcc_to_clang_analyzer/prepare_compiler_commandline'
describe PrepareCompilerCommandline do

  it 'should remove the program name and replace it with clang --analyze when a -c is given' do
    cl, out = PrepareCompilerCommandline.transform(['g++', '-c', 1, 2])
    cl[0...2].should eq(['clang', '--analyze'])
  end

  it 'should remove the program name and replace it with true when no -c is given' do
    cl, out = PrepareCompilerCommandline.transform(['g++', 1, 2])
    cl.first.should eq('true')
  end

  it 'should keep -D flags' do
    cl, out = PrepareCompilerCommandline.transform(['g++', '-c', '-Dflag', '-Dflag2=2'])
    cl.should eq(['clang', '--analyze', '-Dflag', '-Dflag2=2'])
  end

  it 'should keep -I flags' do
    cl, out = PrepareCompilerCommandline.transform(['g++', '-c', '-I/usr/include', '-I/usr/include2'])
    cl.should eq(['clang', '--analyze', '-I/usr/include', '-I/usr/include2'])
  end

  it 'should remove -c' do
    cl, out = PrepareCompilerCommandline.transform(['g++', '-c'])
    cl.should eq(['clang', '--analyze'])
  end

  it 'should remove -MF with a parameter' do
    cl, out = PrepareCompilerCommandline.transform(['g++', '-c', '-MF', 'anotherarg'])
    cl.should eq(['clang', '--analyze'])
  end

  it 'should remove -MMD' do
    cl, out = PrepareCompilerCommandline.transform(['g++', '-c', '-MMD'])
    cl.should eq(['clang', '--analyze'])
  end

  it 'should remove -Wwith values' do
    cl, out = PrepareCompilerCommandline.transform(['g++', '-c', '-Wall'])
    cl.should eq(['clang', '--analyze'])
  end

  it 'should output to the normal output appended with .plist' do
    cl, out = PrepareCompilerCommandline.transform(['g++', '-c', '-o', 'test.o'])
    cl.should eq(['clang', '--analyze', '-o', 'test.o.plist'])
    out.should eq('test.o.plist')
  end

  it 'should let unknown flags pass' do
    cl, out = PrepareCompilerCommandline.transform(['g++', '-c', '-unknown'])
    cl.should eq(['clang', '--analyze', '-unknown'])
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
gcc-to-clang-analyzer-0.0.13 spec/prepare_compiler_commandline_spec.rb
gcc-to-clang-analyzer-0.0.12 spec/prepare_compiler_commandline_spec.rb
gcc-to-clang-analyzer-0.0.11 spec/prepare_compiler_commandline_spec.rb
gcc-to-clang-analyzer-0.0.10 spec/prepare_compiler_commandline_spec.rb
gcc-to-clang-analyzer-0.0.9 spec/prepare_compiler_commandline_spec.rb
gcc-to-clang-analyzer-0.0.8 spec/prepare_compiler_commandline_spec.rb
gcc-to-clang-analyzer-0.0.7 spec/prepare_compiler_commandline_spec.rb
gcc-to-clang-analyzer-0.0.6 spec/prepare_compiler_commandline_spec.rb
gcc-to-clang-analyzer-0.0.5 spec/prepare_compiler_commandline_spec.rb
gcc-to-clang-analyzer-0.0.4 spec/prepare_compiler_commandline_spec.rb
gcc-to-clang-analyzer-0.0.3 spec/prepare_compiler_commandline_spec.rb
gcc-to-clang-analyzer-0.0.2 spec/prepare_compiler_commandline_spec.rb
gcc-to-clang-analyzer-0.0.1 spec/prepare_compiler_commandline_spec.rb