# How to build and test in a subdirectory

**URL:** <https://discuss.circleci.com/t/how-to-build-and-test-in-a-subdirectory/3655>\
**Category:** Build Environment\
**Tags:** circle-yml\
**Created:** [April 28, 2016, 9:13am UTC](https://discuss.circleci.com/t/how-to-build-and-test-in-a-subdirectory/3655 "2016-04-28T09:13:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![manacoa](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/manacoa/32/2681_2.png) [@manacoa](https://discuss.circleci.com/u/manacoa)\
**Post date:** [April 28, 2016, 9:13am UTC](https://discuss.circleci.com/t/how-to-build-and-test-in-a-subdirectory/3655/1 "2016-04-28T09:13:45Z")

</div>

Hi,

I’m looking to do something fairly simple, which is to checkout my repo to a subdirectory, not to $HOME, and to run the tests there.

So instead of checking out to $HOME I would like to

1. Create subdirectories $HOME/catkin\_ws/src
2. Check out the target repo myapp to $HOME/catkin\_ws/src
3. Run the nose tests in $HOME/catkin\_ws/src/myapp/src

I’ve tried two methods:

a) Using build\_dir in circle.yml:

```
general:
  build_dir: catkin_ws/src

```

which gives messages like  
`/opt/circleci/.rvm/scripts/extras/bash_zsh_support/chpwd/function.sh: line 5: cd: /home/ubuntu/myapp/~/catkin_ws/src/: No such file or directory`

b) Using pre commands on checkout:

```
checkout:
   pre:
      - mkdir -p ~/catkin_ws/src
      - cd ~/catkin_ws/src

```

What is the correct way to do this? Thanks!

Simon

Stack: Ubuntu 14.04 + Python 2.7.11

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 18, 2018, 11:38am UTC](https://discuss.circleci.com/t/how-to-build-and-test-in-a-subdirectory/3655/2 "2018-06-18T11:38:18Z")

</div>

Closed on June 18, 2018, 11:38am UTC


