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

how to run a test after that another test finished? #3806

Open
asartori86 opened this issue Jun 29, 2018 · 8 comments
Open

how to run a test after that another test finished? #3806

asartori86 opened this issue Jun 29, 2018 · 8 comments

Comments

@asartori86
Copy link
Contributor

Is there a way to specify to run a test (e.g., diff on generated outputs) after that a test generated those outputs?

My code has a lot of tests that checks the code runs, and in another set of tests the produced output is checked.

We have, e.g., test1 (which runs and produces output files) and test1.compare that compares the output with the reference. This for a lot of tests. Up to now the only solution I came up with is to set the keyword 'is_parallel: falseto all the.comparetests. I don't like this approach since the.compare`s are run only after all the other tests, and in serial.

In CMake you can do this as follows

set_tests_properties(
		"test1.compare" PROPERTIES DEPENDS "test1")

I know I could wrap the run and the diff inside a bash script for example, but I like to have the just_run test such that I can run it with the options provided by meson test like --gdb or --wrapper="valgrind -v"

@jpakkane
Copy link
Member

This is not supported. The common approach here is to alter the build setup so that one test both generates the files and checks that the output is correct. Splitting it in two like that seems a bit arbitrary and strange.

@asartori86
Copy link
Contributor Author

thanks @jpakkane, would you mind to share a snippet of code to show how you would implement that?

@jpakkane
Copy link
Member

jpakkane commented Jul 2, 2018

This has nothing to do with Meson, it is just a question of refactoring your code. In very rough pseudocode you'd go from this:

data_gen_test.c:
int main() {
    return try_to_generate_data(args);
}
data_validat_test.c:
int main() {
    return is_generated_data_valid(args);
}

To a single file with something like:

int main() {
    if(try_to_generate_data(args) != 0) return 1;
    return is_generated_data_valid(args);
}

@asartori86
Copy link
Contributor Author

thanks @jpakkane, I see your point, but that it is not always viable. In my case, the tests generate thousands of files which are compared with scientifically validated files for each test. A comparison written in python or bash is much more suitable in this scenario.

If you give me a hint where to start I could propose a patch for that

@jpakkane
Copy link
Member

jpakkane commented Jul 3, 2018

If you define the first test after the generator tests (or the first test that does file verification) as is_parallel: false Meson will ensure that all tests prior to it have finished, then runs just that one test on its own and only then proceeds with any further tests. If you can define all data generation tests before any validation tests, that should do what you need out of the box.

@asartori86
Copy link
Contributor Author

thanks @jpakkane, that makes sense. I have a question on this: is slicing supported?
I thought I could do something as follows

_t = _tests[0]
test(_t,..., is_parallel: false)
foreach _t : _tests[1:]
  test(_t,..., is_parallel: true)
endforeach

but I got

tests/meson.build:67:25: ERROR:  Expecting rbracket got colon.
    foreach _t : _tests[1:]
                         ^

@pgallir
Copy link

pgallir commented Jul 9, 2018

I think that is not supported because class Parser does not accept column when parsing parenthesis (meson/mesonbuild/mparser.py)

@nirbheek
Copy link
Member

nirbheek commented Aug 7, 2018

Slicing is not supported yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants