# Running single model integration test

**URL:** <https://discourse.mc-stan.org/t/running-single-model-integration-test/5574>\
**Category:** Developers\
**Created:** [September 10, 2018, 4:46pm UTC](https://discourse.mc-stan.org/t/running-single-model-integration-test/5574 "2018-09-10T16:46:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)\
**Post date:** [September 10, 2018, 4:46pm UTC](https://discourse.mc-stan.org/t/running-single-model-integration-test/5574/1 "2018-09-10T16:46:36Z")

</div>

_These are instructions from @syclik on how to test a single model (`.stan` file) for compilability with a `main()` within `stan-dev/stan`._

* * *

Let’s say you wanted to test this Stan file: `src/test/test-models/good/map_rect.stan`

If you type:

```
> make src/test/test-models/good/map_rect.hpp-test

```

then it’ll do a number of things (in this order):

1. `build test/test-models/stanc` — it’s a stripped down version of the compiler

2. generate the C++: it goes from `map_rect.stan` to `map_rect.hpp`

3. the `*-test` target attempts to compile it by including it into a file with a `main()`. That file with the `main()` is generated like this:

```
test/test-model-main.cpp:
	@mkdir -p test
	@touch $@
	@echo "int main() {" >> $@
	@echo " stan::io::var_context *data = NULL;" >> $@
	@echo " stan_model model(*data);" >> $@
	@echo >> $@
	@echo " std::vector<stan::math::var> params;" >> $@
	@echo " std::vector<double> x_r;" >> $@
	@echo " std::vector<int> x_i;" >> $@
	@echo >> $@
	@echo " model.log_prob<false, false>(params, x_i);" >> $@
	@echo " model.log_prob<false, true>(params, x_i);" >> $@
	@echo " model.log_prob<true, false>(params, x_i);" >> $@
	@echo " model.log_prob<true, true>(params, x_i);" >> $@
	@echo " model.log_prob<false, false>(x_r, x_i);" >> $@
	@echo " model.log_prob<false, true>(x_r, x_i);" >> $@
	@echo " model.log_prob<true, false>(x_r, x_i);" >> $@
	@echo " model.log_prob<true, true>(x_r, x_i);" >> $@
	@echo >> $@
	@echo " return 0;" >> $@
	@echo "}" >> $@
	@echo >> $@

```

* * *

Thanks, @syclik.

---

<div class="post-metadata">

**Author:** ![syclik](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/syclik/32/6_2.png) [@syclik](https://discourse.mc-stan.org/u/syclik)\
**Post date:** [September 10, 2018, 5:03pm UTC](https://discourse.mc-stan.org/t/running-single-model-integration-test/5574/2 "2018-09-10T17:03:47Z")

</div>

No prob. Sorry it was so hard to find out how to do that. I’m sure it was on the dev list years ago, but that’s not a reasonable request (asking devs to comb through discussions). Ideally, where should this doc live? Wiki? Or in the `make help` target?

---

<div class="post-metadata">

**Author:** ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)\
**Post date:** [September 10, 2018, 5:39pm UTC](https://discourse.mc-stan.org/t/running-single-model-integration-test/5574/3 "2018-09-10T17:39:16Z")

</div>

I looked in the make help target. Given that @seantalts is planning on replacing make with CMake, I didn’t want to suggest more issues having to do with make.

---

<div class="post-metadata">

**Author:** ![syclik](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/syclik/32/6_2.png) [@syclik](https://discourse.mc-stan.org/u/syclik)\
**Post date:** [September 10, 2018, 5:49pm UTC](https://discourse.mc-stan.org/t/running-single-model-integration-test/5574/4 "2018-09-10T17:49:17Z")

</div>

Sounds like we should put it there, then.

---

<div class="post-metadata">

**Author:** ![sakrejda](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/sakrejda/32/845_2.png) [@sakrejda](https://discourse.mc-stan.org/u/sakrejda)\
**Post date:** [September 10, 2018, 8:23pm UTC](https://discourse.mc-stan.org/t/running-single-model-integration-test/5574/5 "2018-09-10T20:23:27Z")

</div>

Another project I’m working on has been using a `documentation` folder within the github repo for developer documentation. If you use Markdown it’s pretty readable on the command line and great on github and it keeps code + doc in one place. I think it might work well for Stan too. I’m not sure why we struggle with wiki’s and discussions for this stuff.

---

<div class="post-metadata">

**Author:** ![syclik](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/syclik/32/6_2.png) [@syclik](https://discourse.mc-stan.org/u/syclik)\
**Post date:** [September 13, 2018, 3:17am UTC](https://discourse.mc-stan.org/t/running-single-model-integration-test/5574/6 "2018-09-13T03:17:19Z")

</div>

Can you point me to that project? I’ve been looking for good examples, but haven’t found any that stand out.

---

<div class="post-metadata">

**Author:** ![sakrejda](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/sakrejda/32/845_2.png) [@sakrejda](https://discourse.mc-stan.org/u/sakrejda)\
**Post date:** [September 13, 2018, 10:29am UTC](https://discourse.mc-stan.org/t/running-single-model-integration-test/5574/7 "2018-09-13T10:29:45Z")

</div>

Sorry, it’s a private repo :/
