-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add a test that an odd capacity BufEncoder
does not compile
#157
base: master
Are you sure you want to change the base?
Conversation
tests/compiletests.rs
Outdated
config.src_base = PathBuf::from("tests/compiletest"); | ||
config.target_rustcflags = Some("-L target/debug/deps".to_string()); | ||
compiletest::run_tests(&config); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks quite complicated. Why not simply have a new CI step to run if cargo check --something; then exit 1; fi
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure about adding a CI step just for this one, should be simple, test. But it does work, and there might be reasons in the future to add to the compile tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's probably worthwhile to do this in a general way (modifying CI). If we had the means to add compile-tests I'll bet we'd add a lot of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 this would be useful for the api
test files. And also for corepc
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer not to take dev dependency if the same can be done in CI reasonably simply.
7e295d7
to
3394da3
Compare
Cool, looking good. I think this should be called FTR I changed the 3 to a 4 and the crate builds - to check for no false positives. This crate risks going stale consider this:
|
ed6b613
to
5a70ac4
Compare
I have changed it so that there are two compile checks now. First it checks that an even capacity compiles, then it checks that the odd capacity doesn't. The only difference between the two is changing the capacity from 4 to 3. I also moved them to a sub directory in tests called |
Can you add a further subdirectory level |
5a70ac4
to
3e23c88
Compare
I have changed the script to be general using the two sub directories I added the |
3e23c88
to
2751fa4
Compare
Looks good, few
|
Can you put a |
2751fa4
to
24059d2
Compare
Made the changes to the shell script and directory name. |
contrib/compile-tests.sh
Outdated
for dir in pass/*; do | ||
if [ -d "$dir" ]; then | ||
pushd "$dir" > /dev/null | ||
if ! cargo run > /dev/null 2>&1; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test says "compile" but it uses run
. Also we should keep the output here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to build. I have also made it so that it only outputs if the test failed, otherwise for all the shouldn't compile cases there will be a list of compile errors when everything is working as intended.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the pass
branch though.
contrib/compile-tests.sh
Outdated
if [ "$all_passed" = true ]; then | ||
return 0 | ||
else | ||
return 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps just define result = 0
at the beginning and assign it to 1
on fail and just return "$result"
to get rid of if.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is a nicer way of doing it. I have changed it as suggested.
contrib/compile-tests.sh
Outdated
for dir in fail/*; do | ||
if [ -d "$dir" ]; then | ||
pushd "$dir" > /dev/null | ||
if cargo run > /dev/null 2>&1; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also it should be build
, not run
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
contrib/compile-tests.sh
Outdated
if [ "$all_failed" = true ]; then | ||
return 0 | ||
else | ||
return 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
24059d2
to
d91a533
Compare
for dir in pass/*; do | ||
if [ -d "$dir" ]; then | ||
pushd "$dir" > /dev/null | ||
output=$(cargo build 2>&1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be needed but I guess it's OK. I don't expect the output to be too large.
contrib/compile-tests.sh
Outdated
pushd "$dir" > /dev/null | ||
output=$(cargo build 2>&1) | ||
if [ $? -eq 0 ]; then | ||
echo "$output" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If compilation succeeded and it shouldn't there will be no useful information printed by cargo
. I'd rather get rid of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed the cargo output for this case
d91a533
to
82918e6
Compare
Looking at the script again I noticed the two functions are now basically identical. I have refactored it to have a single function that handles both cases. |
Create a script `contrib/compile-tests.sh` the checks that all crates in `tests/compiletests/` do compile if in `pass/` and fail to compile if in `fail/` Add a CI step to run the script
Add two compile test crates that are identical except for the capacity of `BufEncoder`. Odd capacity in `fail/` that must not compile and even capacity in `pass/` that must compile.
82918e6
to
853f493
Compare
echo "Compiling $dir" | ||
output=$(cargo build 2>&1) | ||
if [ "$?" -ne "$expected_status" ]; then | ||
if [ "$expected_status" -eq 0 ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have another argument if it can be inferred from the first one and you're not comparing them anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started to change it, but it's more flexible the way it is. I'm not sure we need to but it's possible to check directories other than pass/
and fail/
by passing a different argument to the function.
But if you prefer I can hard code the directory names and exit codes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too many possibilities that we're not using are just complicating the code. Honestly, I think even having the pass
option is a stretch (normal tests do that already!) but I understand it's for the symmetry since there are related test (one for 3, other 4) so I'm accepting it. I was really expecting this to be one line in the workflow file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 853f493
An even capacity
BufEncoder
is now enforced and should be tested to make sure it does not compile if an odd capacity is used.Adds a crate in tests that uses an odd capacity
BufEncoder
.Adds a CI test that passes if the odd capacity crate fails to compile.
Close #155