# Copyright 2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# Auto-Generated by cargo-ebuild 0.5.4-r1

EAPI=8

CRATES="
	addr2line@0.19.0
	adler@1.0.2
	aes@0.8.3
	aho-corasick@1.0.2
	android-tzdata@0.1.1
	android_system_properties@0.1.5
	anstream@0.6.11
	anstyle@0.3.5
	anstyle@1.0.6
	anstyle-parse@0.2.1
	anstyle-query@1.0.0
	anstyle-wincon@3.0.1
	anyhow@1.0.82
	apple-flat-package@0.18.0
	apple-xar@0.18.0
	ar@0.9.0
	arrayvec@0.7.4
	assert_cmd@2.0.14
	autocfg@1.1.0
	backtrace@0.3.67
	base64@0.21.7
	base64@0.22.0
	base64ct@1.6.0
	bcder@0.7.4
	bit-set@0.5.3
	bit-vec@0.6.3
	bitflags@1.3.2
	bitflags@2.4.0
	block-buffer@0.10.4
	bstr@1.4.0
	bumpalo@3.12.0
	byteorder@1.5.0
	bytes@1.6.0
	bzip2@0.4.4
	bzip2-sys@0.1.11+1.0.8
	cc@1.0.90
	cfb@0.7.3
	cfg-if@1.0.0
	chrono@0.4.31
	cipher@0.4.4
	clap@4.5.4
	clap_builder@4.5.2
	clap_derive@4.5.4
	clap_lex@0.7.0
	colorchoice@1.0.0
	const-oid@0.9.6
	constant_time_eq@0.1.5
	core-foundation@0.9.3
	core-foundation-sys@0.8.4
	cpio-archive@0.9.0
	cpufeatures@0.2.5
	crc@3.0.1
	crc-catalog@2.2.0
	crc32fast@1.3.2
	crossbeam-utils@0.8.15
	crypto-common@0.1.6
	cryptographic-message-syntax@0.26.0
	debpkg@0.6.0
	der@0.7.8
	deranged@0.3.11
	difflib@0.4.0
	digest@0.10.7
	directories@5.0.1
	dirs-sys@0.4.1
	doc-comment@0.3.3
	either@1.8.1
	encoding_rs@0.8.32
	env_filter@0.1.0
	env_logger@0.11.3
	equivalent@1.0.0
	errno@0.3.8
	exitcode@1.1.2
	fastrand@2.0.1
	filetime@0.2.23
	filetime_creation@0.2.0
	flate2@1.0.28
	fnv@1.0.7
	form_urlencoded@1.2.1
	futures@0.3.27
	futures-channel@0.3.27
	futures-core@0.3.27
	futures-executor@0.3.27
	futures-io@0.3.27
	futures-macro@0.3.27
	futures-sink@0.3.27
	futures-task@0.3.27
	futures-timer@3.0.2
	futures-util@0.3.27
	generic-array@0.14.6
	getrandom@0.2.12
	gimli@0.27.3
	glob@0.3.1
	h2@0.3.17
	hashbrown@0.12.3
	hashbrown@0.14.0
	heck@0.5.0
	hermit-abi@0.2.6
	hex@0.4.3
	hmac@0.12.1
	http@0.2.9
	http@1.1.0
	http-body@0.4.5
	http-body@1.0.0
	http-body-util@0.1.1
	httparse@1.8.0
	httpdate@1.0.2
	humantime@2.1.0
	hyper@0.14.25
	hyper@1.2.0
	hyper-rustls@0.24.0
	hyper-rustls@0.26.0
	hyper-util@0.1.3
	iana-time-zone@0.1.60
	iana-time-zone-haiku@0.1.2
	idna@0.5.0
	indexmap@1.9.2
	indexmap@2.0.0
	infer@0.8.1
	infer@0.15.0
	inout@0.1.3
	ipnet@2.7.1
	is_executable@1.0.1
	itertools@0.10.5
	itoa@1.0.6
	jobserver@0.1.26
	js-sys@0.3.66
	libc@0.2.153
	linux-raw-sys@0.4.13
	log@0.4.21
	lzma-rust@0.1.6
	lzma-sys@0.1.20
	md-5@0.10.6
	memchr@2.6.4
	mime@0.3.17
	miniz_oxide@0.6.2
	miniz_oxide@0.7.1
	mio@0.8.9
	nt-time@0.6.5
	num-traits@0.2.16
	num_cpus@1.15.0
	object@0.30.4
	once_cell@1.17.1
	option-ext@0.2.0
	password-hash@0.4.2
	pbkdf2@0.11.0
	pem@3.0.3
	percent-encoding@2.3.1
	pin-project@1.1.5
	pin-project-internal@1.1.5
	pin-project-lite@0.2.12
	pin-utils@0.1.0
	pkg-config@0.3.26
	powerfmt@0.2.0
	ppv-lite86@0.2.17
	predicates@3.0.1
	predicates-core@1.0.6
	predicates-tree@1.0.9
	proc-macro2@1.0.78
	quote@1.0.35
	rand@0.8.5
	rand_chacha@0.3.1
	rand_core@0.6.4
	redox_syscall@0.2.16
	redox_syscall@0.4.1
	redox_users@0.4.3
	regex@1.10.4
	regex-automata@0.1.10
	regex-automata@0.4.5
	regex-syntax@0.8.2
	relative-path@1.9.0
	reqwest@0.11.26
	reqwest@0.12.3
	ring@0.16.20
	ring@0.17.8
	rstest@0.19.0
	rstest_macros@0.19.0
	rustc-demangle@0.1.23
	rustc_version@0.4.0
	rustix@0.38.31
	rustls@0.21.6
	rustls@0.22.3
	rustls-pemfile@1.0.2
	rustls-pemfile@2.1.2
	rustls-pki-types@1.4.1
	rustls-webpki@0.101.4
	rustls-webpki@0.102.2
	ryu@1.0.13
	same-file@1.0.6
	scroll@0.12.0
	scroll_derive@0.12.0
	sct@0.7.0
	semver@1.0.17
	serde@1.0.197
	serde-xml-rs@0.6.0
	serde_derive@1.0.197
	serde_json@1.0.115
	serde_spanned@0.6.5
	serde_urlencoded@0.7.1
	sevenz-rust@0.6.0
	sha1@0.10.6
	sha2@0.10.8
	signature@2.2.0
	simple-file-manifest@0.11.0
	slab@0.4.8
	smallvec@1.13.2
	socket2@0.4.9
	socket2@0.5.5
	spin@0.5.2
	spin@0.9.8
	spki@0.7.3
	strsim@0.11.0
	subtle@2.5.0
	syn@1.0.109
	syn@2.0.48
	sync_wrapper@0.1.2
	system-configuration@0.5.1
	system-configuration-sys@0.5.0
	tar@0.4.40
	tempfile@3.10.1
	termtree@0.4.1
	thiserror@1.0.58
	thiserror-impl@1.0.58
	time@0.3.31
	time-core@0.1.2
	time-macros@0.2.16
	tinyvec@1.6.0
	tinyvec_macros@0.1.1
	tokio@1.37.0
	tokio-macros@2.2.0
	tokio-rustls@0.24.1
	tokio-rustls@0.25.0
	tokio-util@0.7.7
	toml@0.8.12
	toml_datetime@0.6.5
	toml_edit@0.22.9
	tower@0.4.13
	tower-layer@0.3.2
	tower-service@0.3.2
	tracing@0.1.37
	tracing-core@0.1.30
	try-lock@0.2.4
	typenum@1.16.0
	unicode-bidi@0.3.13
	unicode-ident@1.0.8
	unicode-normalization@0.1.22
	untrusted@0.7.1
	untrusted@0.9.0
	url@2.5.0
	utf8parse@0.2.1
	uuid@1.3.0
	version_check@0.9.4
	wait-timeout@0.2.0
	walkdir@2.5.0
	want@0.3.0
	wasi@0.11.0+wasi-snapshot-preview1
	wasm-bindgen@0.2.89
	wasm-bindgen-backend@0.2.89
	wasm-bindgen-futures@0.4.34
	wasm-bindgen-macro@0.2.89
	wasm-bindgen-macro-support@0.2.89
	wasm-bindgen-shared@0.2.89
	web-sys@0.3.61
	webpki-roots@0.25.2
	webpki-roots@0.26.1
	winapi@0.3.9
	winapi-i686-pc-windows-gnu@0.4.0
	winapi-util@0.1.5
	winapi-x86_64-pc-windows-gnu@0.4.0
	windows-core@0.52.0
	windows-sys@0.48.0
	windows-sys@0.52.0
	windows-targets@0.48.1
	windows-targets@0.52.0
	windows_aarch64_gnullvm@0.48.0
	windows_aarch64_gnullvm@0.52.0
	windows_aarch64_msvc@0.48.0
	windows_aarch64_msvc@0.52.0
	windows_i686_gnu@0.48.0
	windows_i686_gnu@0.52.0
	windows_i686_msvc@0.48.0
	windows_i686_msvc@0.52.0
	windows_x86_64_gnu@0.48.0
	windows_x86_64_gnu@0.52.0
	windows_x86_64_gnullvm@0.48.0
	windows_x86_64_gnullvm@0.52.0
	windows_x86_64_msvc@0.48.0
	windows_x86_64_msvc@0.52.0
	winnow@0.6.5
	winreg@0.50.0
	winreg@0.52.0
	x509-certificate@0.23.1
	xattr@1.0.1
	xml-rs@0.8.19
	xz2@0.1.7
	zeroize@1.7.0
	zeroize_derive@1.4.2
	zip@0.6.6
	zstd@0.11.2+zstd.1.5.2
	zstd-safe@5.0.2+zstd.1.5.2
	zstd-sys@2.0.7+zstd.1.5.4
"

inherit cargo

DESCRIPTION="CLI tool that manages the browser/driver infrastructure required by Selenium"
# Double check the homepage as the cargo_metadata crate
# does not provide this value so instead repository is used
HOMEPAGE="https://github.com/SeleniumHQ/selenium"
SRC_URI="
	${CARGO_CRATE_URIS}
	https://github.com/SeleniumHQ/selenium/archive/refs/tags/selenium-${PV}.tar.gz -> ${P}.tar.gz
"
S="${WORKDIR}/selenium-selenium-${PV}/rust"

# License set may be more restrictive as OR is not respected
# use cargo-license for a more accurate license picture
LICENSE="0BSD Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD Boost-1.0 CC0-1.0 ISC MIT MPL-2.0 Unicode-DFS-2016 Unlicense ZLIB"
SLOT="0"
KEYWORDS="~amd64 ~ppc64 ~riscv ~x86"
IUSE="test"
RESTRICT="!test? ( test )"

DEPEND=""
RDEPEND="${DEPEND}"
BDEPEND="test? ( || ( www-client/firefox www-client/firefox-bin ) )"

# rust does not use *FLAGS from make.conf, silence portage warning
# update with proper path to binaries this crate installs, omit leading /
QA_FLAGS_IGNORED="usr/bin/${PN}"

src_prepare() {
	default

	# Avoid tests requiring a network
	rm -f tests/{browser_download,chrome_download,grid}_tests.rs || die

	# Avoid tests requiring a specific browser to be installed to keep
	# the dependency tree manageable.
	rm -f tests/{cli,iexplorer,output,safari,stable_browser}_tests.rs || die
	sed -i -e '/case.*\(chrome\|edge\|iexplorer\)/ s:^://:' tests/{browser,config,exec_driver}_tests.rs || die
	sed -e '/browser_version_test/,/^}/ s:^://:' \
		-e '/#\[test\]/,/^}/ s:^://:' \
		-i tests/browser_tests.rs || die
}

src_install() {
	default

	cargo_src_install

	dodoc README.md
}