Skip to content

Commit 8b97ea8

Browse files
committed
lib/programs.rb: remove legacy LKP_SRC search paths
The tests/monitors/setup/daemon directory under LKP_SRC is deprecated. Update program lookup logic to only search within PROGRAMS_ROOT. Signed-off-by: Philip Li <philip.li@intel.com>
1 parent aab1eb6 commit 8b97ea8

2 files changed

Lines changed: 21 additions & 21 deletions

File tree

lib/programs.rb

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Programs
1010

1111
class << self
1212
def collect_programs(lkp_src_pattern, programs_pattern, executable_only: false)
13-
lkp_files = Dir["#{LKP_SRC}/#{lkp_src_pattern}"]
13+
lkp_files = lkp_src_pattern ? Dir["#{LKP_SRC}/#{lkp_src_pattern}"] : []
1414
prog_files = Dir["#{PROGRAMS_ROOT}/#{programs_pattern}"]
1515

1616
if executable_only
@@ -22,10 +22,9 @@ def collect_programs(lkp_src_pattern, programs_pattern, executable_only: false)
2222
end
2323

2424
def find_executable(program, lkp_dir, *prog_names)
25-
[
26-
*prog_names.map { |n| "#{PROGRAMS_ROOT}/#{program}/#{n}" },
27-
"#{LKP_SRC}/#{lkp_dir}/#{program}"
28-
].find { |file| File.exist?(file) }
25+
candidates = prog_names.map { |n| "#{PROGRAMS_ROOT}/#{program}/#{n}" }
26+
candidates << "#{LKP_SRC}/#{lkp_dir}/#{program}" if lkp_dir
27+
candidates.find { |file| File.exist?(file) }
2928
end
3029

3130
def all_stats
@@ -35,21 +34,21 @@ def all_stats
3534
alias all_parser_names all_stats
3635

3736
def all_tests
38-
collect_programs('tests/**/*', '*/run')
37+
collect_programs(nil, '*/run')
3938
end
4039

4140
alias all_runner_names all_tests
4241

4342
def all_monitors
44-
collect_programs('monitors/*', '*/{monitor,no-stdout-monitor,one-shot-monitor}', executable_only: true)
43+
collect_programs(nil, '*/{monitor,no-stdout-monitor,one-shot-monitor}', executable_only: true)
4544
end
4645

4746
def all_setups
48-
collect_programs('setup/**/*', '*/setup', executable_only: true)
47+
collect_programs(nil, '*/setup', executable_only: true)
4948
end
5049

5150
def all_daemons
52-
collect_programs('daemon/**/*', '*/daemon', executable_only: true)
51+
collect_programs(nil, '*/daemon', executable_only: true)
5352
end
5453

5554
def all_tests_and_daemons
@@ -61,13 +60,12 @@ def all_tests_set
6160
end
6261

6362
def all_metas
64-
Dir["#{LKP_SRC}/tests/*.yaml"] + Dir["#{PROGRAMS_ROOT}/*/meta.yaml"]
63+
Dir["#{PROGRAMS_ROOT}/*/meta.yaml"]
6564
end
6665

6766
def find_meta(program)
6867
[
69-
"#{PROGRAMS_ROOT}/#{program}/meta.yaml",
70-
"#{LKP_SRC}/tests/#{program}.yaml"
68+
"#{PROGRAMS_ROOT}/#{program}/meta.yaml"
7169
].find { |file| File.exist?(file) }
7270
end
7371

@@ -76,19 +74,19 @@ def find_parser(program)
7674
end
7775

7876
def find_setup(program)
79-
find_executable(program, 'setup', 'setup')
77+
find_executable(program, nil, 'setup')
8078
end
8179

8280
def find_monitor(program)
83-
find_executable(program, 'monitors', 'monitor', 'no-stdout-monitor', 'one-shot-monitor')
81+
find_executable(program, nil, 'monitor', 'no-stdout-monitor', 'one-shot-monitor')
8482
end
8583

8684
def find_daemon(program)
87-
find_executable(program, 'daemon', 'daemon')
85+
find_executable(program, nil, 'daemon')
8886
end
8987

9088
def find_runner(program)
91-
find_executable(program, 'tests', 'run')
89+
find_executable(program, nil, 'run')
9290
end
9391

9492
# program: turbostat, turbostat-dev

spec/programs_spec.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,20 @@
4141
end
4242

4343
describe '.all_tests' do
44-
it 'finds all tests from tests/ and programs/*/run' do
45-
expect(described_class.all_tests).to include('mytest', 'progtest')
44+
it 'finds all tests from programs/*/run' do
45+
expect(described_class.all_tests).to include('progtest')
46+
expect(described_class.all_tests).not_to include('mytest')
4647
end
4748
end
4849

4950
describe '.all_tests_and_daemons' do
5051
it 'finds all tests' do
51-
expect(described_class.all_tests_and_daemons).to include('mytest', 'progtest')
52+
expect(described_class.all_tests_and_daemons).to include('progtest')
53+
expect(described_class.all_tests_and_daemons).not_to include('mytest')
5254
end
5355

54-
it 'finds daemons in daemon/' do
55-
expect(described_class.all_tests_and_daemons).to include('olddaemon')
56+
it 'ignores daemons in legacy daemon/' do
57+
expect(described_class.all_tests_and_daemons).not_to include('olddaemon')
5658
end
5759

5860
it 'finds daemons in programs/*/daemon' do

0 commit comments

Comments
 (0)