Files
chromebrew/tests/cycle_test.rb
chromebrew-actions[bot] 614f0d183e Remove libwebp from libtiff deps and build to avoid circular dependency. — libtiff: 4.7.1 → 4.7.1-1, Adjust automatic updater logic. (#14338)
* Remove libwebp from libtiff deps and build to avoid circular dependency.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add sphinx dep needed for documentation generation.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* libtiff_without_libwebp: Package File Update Run on linux/386 container.

* libtiff_without_libwebp: Package File Update Run on linux/amd64 container.

* libtiff_without_libwebp: Package File Update Run on linux/arm/v7 container.

* Adjust package testing infrastructure.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add pnpm package (#14339)

* Update Rubocop, handle gem outdated sources edge condition (#14336)

* Add unbuilt ruby_rubocop to updater-ruby_rubocop-1.84.0-ruby4.0

* Adjust to avoid circular dependency.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add fallback for outdated gem cache.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Document reason for new require_gem rescue block.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add package_utils fallback if gitlab response is not json.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Only do a gem check for the gem being installed.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

---------

Signed-off-by: Satadru Pramanik <satadru@gmail.com>
Co-authored-by: satmandu <satmandu@users.noreply.github.com>
Co-authored-by: Satadru Pramanik <satadru@gmail.com>

* Rename rest of ruby files in tests/

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Adjust automatically updatable package workflows.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Fix package test invocation.

* Fix test extensions.

* Update package listing command in Updater.yml

* Fix syntax for package retrieval in Updater.yml

* Update Updater.yml

* Fix run command for getting updatable packages

* Update SHELLCHECK_OPTS

* Adjust automatically updatable packages check in version.rb

* lint

---------

Signed-off-by: Satadru Pramanik <satadru@gmail.com>
Co-authored-by: Satadru Pramanik <satadru@gmail.com>
Co-authored-by: chromebrew-actions[bot] <chromebrew-actions[bot]@users.noreply.github.com>
Co-authored-by: Ed Reel <edreel@gmail.com>
Co-authored-by: chromebrew-actions[bot] <220035932+chromebrew-actions[bot]@users.noreply.github.com>
Co-authored-by: satmandu <satmandu@users.noreply.github.com>
2026-01-28 00:33:26 +00:00

69 lines
1.6 KiB
Ruby
Executable File

#!/usr/bin/env ruby
# This test checks whether the packages create a dependency cycle.
require 'find'
require_relative '../lib/const'
require_relative '../lib/color'
require_relative '../lib/package'
# Add >LOCAL< lib to LOAD_PATH so that packages can be loaded
$LOAD_PATH.unshift File.join(CREW_LIB_PATH, 'lib')
@all_pkgs = {}
puts "Running dependency cycle tests...\n".yellow
# Loads all packages
Dir['../packages/*.rb'].each do |filename|
name = File.basename(filename, '.rb')
pkg = Package.load_package(filename)
@all_pkgs[name] = pkg
end
# Looking for cycles. @path will keep the current dependency path.
# @state will store :on_path for vertices on the current dependency path
# and :visited for vertices that have already been checked not to lead to
# cycles.
@failed = 0
@state = {}
@path = []
@uniq_path = []
def dfs(pkg)
@path.push(pkg.name)
case @state[pkg]
when :on_path
@path.shift while @path.first != @path.last
if (!@uniq_path.include? @path.to_s) && @path.to_s.include?(',')
@uniq_path.push(@path.to_s)
@failed += 1
end
when nil
@state[pkg] = :on_path
pkg.dependencies&.each_key do |name|
dfs(@all_pkgs[name]) if name != pkg.name
end
@state[pkg] = :visited
end
@path.pop
end
# Calls dfs for every path
@all_pkgs.each_value do |pkg|
dfs(pkg)
end
# Display dependency cycles
@uniq_path.sort.each do |path|
puts path.lightred
end
@cycles = 'cycles'
@cycles = 'cycle' if @failed == 1
if @failed.positive?
abort "\n#{@failed} dependency #{@cycles} found.".lightred
else
puts "\nNo dependency cycles found.".lightgreen
end