Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Guide and exercise for uploading the correct artifacts for Source Control

Options
Billy McMullin
Billy McMullin Posts: 64 admin
edited May 2018 in C/C++test

What Files should be Checked into Source Control?

When using Source control with C/C++test, make sure to have the following files checked-in:

  1. .parasoft
  2. .cproject
  3. .project
  4. All source files that are needed for the project
  5. Test Folders or other folder(s) you use for your Test Suites
  6. Stubs Folders or other folder(s) you use for your Stubs

Note:

  • Do not check in temporary data/files (such as instrumented sources, compiled objects, linked test executable, and automatically-generated header files) with the project. By default, temporary files are in the .cpptest directory of the current workspace. These files should not be stored in source control because C++test can automatically regenerate these as needed.

Project’s configuration after checkout.

After the project is checked out, make sure the project settings are configured correctly. If the project was not correctly configured then the analysis may not work properly as it may not be able to find any of the source files. You can configure the project’s settings by Right-clicking on the root project’s folder and selecting “Properties”. From the Properties window go to “Parasoft->C++test->Build Settings”. Here you can configure how C/C++test will find the project’s information to run analysis on. You can set the project’s settings by clicking on the “Options Source” dropdown at the top and selecting an valid option for your project to run with.

Note:

  • The Linux installation doesn’t have as many options available as not all the options are supported in the Linux Environment.

Exercise

For this exercise, we will be using an example project that come with C/C++test and we will be using Subversion four our Source Control. We will also be using the IDE to prepare the project as we would have to manually write our settings for some of them. We will be going through:

  • Configuring the build settings to properly run your tests
  • Configuring the Test Configuration to be shareable
  • (optional) Configuring the machine for Custom Compiler definitions.
  • Committing the correct files for Source Control
  • Checking out the project and running a test
  1. We will begin by configuring the project’s Build Settings. You can get there from your IDE by right-clicking your project and selecting “Properties”. This will open the Properties Window for the project. The Build Settings are located at “Parasoft->C++test->Build Settings”.
  2. Since the BDF has absolute paths based on the machine it was created on, we need to change the Build Settings to use “Use options from a build system” from the drop down. This will configure the project to use whatever build system is used to compile and link the project. This is how C/C++test can find and scan source files for Static Analysis.
  3. Now that the project’s Build Settings have been configured, we will commit the project and the required artifacts. We will commit the following files:
    a. .parasoft
    b. .cproject
    c. .project
    d. All source files from the project
    e. Any Unit Test folders or other folders for the project
    f. Any Stub Folders or other folders required for the project.
    g. (optional) Custom Compiler Definition file.
    Note:
  • Do not commit the BDF for the project or executable made from the project’s build.
  1. Now that the Project has been committed with Source Control, we are ready to check out the project on another machine to run our tests.

  2. Go to a new machine and check out this project from Source Control. After the project is checked out, go ahead and run a test on it.
    Note:

  • If the project is showing “0/0” files scanned, check the console output. The console output will display what it was trying to do when the test began. You might have to make sure the build utility is available on the PATH. For example make sure that GNU Make is available on the System PATH.

Comments

  • benken_parasoft
    benken_parasoft Posts: 1,230 ✭✭✭
    edited November 2019
    Options

    Do not check in temporary data/files (such as instrumented sources, compiled objects, linked test executable, and automatically-generated header files) with the project.

    Many useful .gitignore templates found here, including this one for C++:
    https://github.com/github/gitignore/blob/master/C++.gitignore

    Of course, those templates don't include patterns for any Parasoft specific artifacts like bdf. However, those could be manually added as needed.

  • Andrey Madan
    Andrey Madan Posts: 388 ✭✭✭
    Options

    One important decision a customer should make is where to store project files. The best location for project files is at the top of the source directory, not inside the workspace. So when you are creating a project from BDF, select use external location and then place it at the top of your source tree.

    This is because eclipse will be able to find all sources to the project without specifying Linked Folders.

    Another option is to dedicate a special folder for projects:
    e.g.:
    /src
    /tests
    /build
    /parasoftsetup -> projects, config files , options will be here
    but in this case project files will have to contain references to /src and /tests directories. Which is also an option.

    You can place those project files anywhere else, but then the eclipse project file will have Linked Folders for eclipse to be able to find source files, tests, etc. During project creation process those folders will be created with a full system path. In order to create a shareable .project file, you will need to convert Linked Folders from absolute to relative paths:

    Linked Folders
    https://help.eclipse.org/2019-12/index.jsp?topic=/org.eclipse.platform.doc.user/tasks/tasks-45.htm