Skip to content

Test case directory and project structure in tmc langs

nucularmoo edited this page Mar 13, 2018 · 23 revisions

Test cases are located in the tmc-langs project.

Test case directory structure and library file naming policy

For each test case there exists a subdirectory where the relevant test case project file is located. In addition to the project file, each test case directory also contains the following subdirectories:

src contains the test case project file and relevant source and header files. test_case_test_runner contains the test runner project file and relevant source and header files. test_case_libs contains the library project file and relevant source and header files. This directory is only included for projects that make use of libraries. It is worth noting that in the test case of multiple libraries, each library is contained in it's own subdirectory, following a naming scheme of test_case_lib, test_case_lib2 and so on. The project, source and header file names for each library will reflect the name of the library directory to avoid confusion regarding library files.

Test cases:

passing_nolib - tests passing with no library included in the project

passing_nolib_same_point - as above with the addition of multiple tests for function two*

passing_single_lib - tests passing with one library included in the project

passing_single_lib_same_point - as above with the addition of multiple tests for function two*

passing_multiple_lib - tests passing with multiple libraries included in the project

passing_multiple_lib_same_point - as above with the addition of multiple tests for function two*

failing_nolib - tests failing with no library included in the project

failing_nolib_same_point - as above with the addition of multiple tests for function two*

failing_single_lib - tests failing with one library included in the project

failing_single_lib_same_point - as above with the addition of multiple tests for function two*

failing_single_lib_not_compiling - build failing with one library included in the project, said library failing to compile

failing_compile_single_lib_compiling - build failing with one library included in the project, said library compiling as intended

*For clarification - starred test cases are used for a single function being tested with several tests, each of these tests awarding a different amount of points. This is done in consideration of there being a situation where passing multiple tests may be required to pass in order to reward score credit, for example.

Test case project structure within Qt Creator

Test case project structure follows our proposed structure for testing projects using the tmc-plugin.

The top level .pro file for the project defines the project to be using the SUBDIRS template. It also defines the location of the app, libraries and test runner and their corresponding dependencies.

The app, libraries and test runner all have their own corresponding headers, sources and .pro files.

Resolving library linking issues for Windows

For Windows, the qmake debug_and_release and debug_and_release_target CONFIG variable options are enabled by default, resulting in libraries linking incorrectly when compiling as well as directory clutter for our subdirectories. To avoid this, we will always disable these options in each respective `.pro file with the following code:

win32 {
    CONFIG -= debug_and_release debug_and_release_target
}

When present in the test_case_lib .pro file, disabling these CONFIG variable options will allow libraries to be correctly linked when building projects using Windows. Building with these options enabled will always result in the compile failing.

When present in the src and test_case_test_runner .pro files, we prevent redundant directories from spawning in the respective build folders.

This is at the time of writing mandatory for projects with libraries to compile correctly for Windows users.

If for some reason you would need to resolve the aforementioned issues manually, please take the following steps:

  1. Having opened your desired project, click on the Projects button in the side pane.
  2. Click on the Details option under the Build Steps element
  3. Under Additional arguments, please add the line "CONFIG -= debug_and_release debug_and_release_target"

Your libraries should now compile under correct directories when using Windows. This setting is stored in your project .user file.

Image overview of project structure in Qt Creator

*NB: test_case_app has been renamed to src

Project view of test cases

Project without library fully expanded

Project with library fully expanded

Showcasing structure of multiple libraries in a project


TODO:

Once the qmake support branch is merged with the original tmc-langs repo, include test case directory links for each test case in the repo to the description of the test case.

If there is time/BONUS LEVEL: add one more test case for simple testing of a simple user interface element.

Clone this wiki locally