Skip to content

Commit

Permalink
Add autoconf-archive detector
Browse files Browse the repository at this point in the history
  • Loading branch information
fd00 committed Feb 10, 2024
1 parent 46147f1 commit 0b9e164
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lib/xezat/detector/autoconf-archive.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

module Xezat
module Detector
class AutoconfArchive
def detect(variables)
Find.find(variables[:S]) do |file|
next unless file.end_with?("#{File::SEPARATOR}configure.ac", "#{File::SEPARATOR}configure.in")

File.foreach(file) do |line|
return true if line.strip.start_with?('AX_')
end
end
false
end
end
end
end
26 changes: 26 additions & 0 deletions spec/detector/autoconf-archive_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

require 'facets/file/atomic_write'
require 'fileutils'
require 'spec_helper'
require 'tmpdir'
require 'xezat/detector/autoconf-archive'

describe Xezat::Detector::AutoconfArchive do
it 'contains AX_* in configure.ac' do
tmpdir = Dir.mktmpdir
File.atomic_write(File.expand_path(File.join(tmpdir, 'configure.ac'))) do |f|
f.puts('AX_COMPILER_FLAGS(')
end
detector = Xezat::Detector::AutoconfArchive.new
expect(detector.detect(S: tmpdir)).to be_truthy
end
it 'contains no AX_* in configure.ac' do
tmpdir = Dir.mktmpdir
File.atomic_write(File.expand_path(File.join(tmpdir, 'configure.ac'))) do |f|
f.puts('AC_INIT(')
end
detector = Xezat::Detector::AutoconfArchive.new
expect(detector.detect(S: tmpdir)).to be_falsey
end
end

0 comments on commit 0b9e164

Please sign in to comment.