Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Granular controls for testing? #29

Open
kentfredric opened this issue Feb 10, 2020 · 5 comments
Open

Granular controls for testing? #29

kentfredric opened this issue Feb 10, 2020 · 5 comments
Labels
discussion ideas, thoughts and meta issues that may or may not eventually lead to some concrete change

Comments

@kentfredric
Copy link
Member

Just some food for thought atm:

src_test() {
	einfo "Building default test suite"
	ecargo build --tests --lib || die "building default test suite failed"
	einfo "Running default test suite"
	ecargo test --tests || die "ecargo test --tests failed"
	einfo "Running doc tests"
	ecargo test --doc || die "ecargo test --doc failed"
	for i in i128 $(usev rand) $(usev serde); do
		einfo "Building test suite with --features ${i}"
		ecargo build --features "${i}" --tests --lib || die "Building test suite with --features ${i} failed"
		einfo "Testing with --features ${i}"
		ecargo test --features "${i}" --tests || die "Running test suite with --features ${i} failed"
		einfo "Running doc tests with --features ${i}"
		ecargo test --features "${i}" --doc || die "Running doc tests with --features ${i} failed"
	done
}

This is just a prototype pattern for something which I'd like to see native eclass support for.

Maybe have a bash array like:

ECARGO_TEST_TARGETS=(
   "default/test,doc"
   "i128/test,doc"
   "rand/test,doc,if_use"
   "serde/test,doc,if_use"
)

Where:

"feature/params"

And params are something like:

test : do cargo test --tests
doc: do cargo test --doc
if_use: only do testing on this feature if the feature is both in IUSE and USE ( and warning if not in IUSE )
build_only: do `cargo build --lib` with the features needed, but don't compile (or run) tests.

Values without "/" are interpreted as:

  "foo"   -> "foo/test" # when "foo" is *not* in IUSE
  "foo"  -> "foo/test,if_use" # when "foo" *is* in IUSE

And the default value for the array is:

ECARGO_TEST_TARGETS=(
   "default/test"
)

We could special case "default" to never pass --features, but given --features default works just fine, and you need to have a feature named 'default' in order to have defaulted features ... it seems YAGNI, yet.

@kentfredric kentfredric added the question Further information is requested label Feb 10, 2020
@kentfredric kentfredric added discussion ideas, thoughts and meta issues that may or may not eventually lead to some concrete change and removed question Further information is requested labels Feb 10, 2020
@kentfredric
Copy link
Member Author

kentfredric commented Feb 10, 2020

Hmm, actually, the more I think about it, the use-conditional testing seems pretty stupid.

As is, there is no way to make cargo test run without having all the dependencies present, so we have to have all deps for USE="test", which means we can run every test. There may be a potential use [heh] for such a switch, but not for this purpose.

Like for instance, if the deps could be conditionally patched out as well, then it might make sense, but we VERY MUCH SHOULD NOT BE DOING THIS AT ANY KIND OF SCALE, ( at least, not for testing purposes )

@kentfredric
Copy link
Member Author

We could special case "default" to never pass --features, but given --features default works just fine, and you need to have a feature named 'default' in order to have defaulted features ... it seems YAGNI, yet.

Nope. That's wrong, because .... if a crate doesn't have any default feature, then --features default fails.

And we can't have that being a default :D

Special-casing required.

@kentfredric
Copy link
Member Author

Though ... hmm.

   cargo test --features ""

>_> 😰

@kentfredric
Copy link
Member Author

Supporting messes like this may be tricky though. Hmm.

src_test() {
	# std required due to [not( feature = std ),feature...]
	local targets=(
		''
		arrayvec
		correct
		default
		dtoa
		grisu3
		radix
		rounding
		ryu
		table
		trim_floats
		unchecked_index
		# --all-features can't work because ryu and grius3 are mutex
		"ryu default arrayvec correct dtoa radix rounding table trim_floats unchecked_index"
		"grius3 arrayvec correct dtoa radix rounding table trim_floats unchecked_index"
	)
	for i in "${targets[@]}"; do
		einfo "Testing --features 'std $i'"
		ecargo test --no-default-features --features "std ${i}" || die "Test suite with --features ${i} failed"
	done
}

@kentfredric
Copy link
Member Author

Nah, gonna need to rethink this.

		''
		# alloc w/o std uses nightly feature(alloc)
		"std alloc"
		default
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion ideas, thoughts and meta issues that may or may not eventually lead to some concrete change
Projects
None yet
Development

No branches or pull requests

1 participant