From 6b80fc4ca5edf14a161a9f6482d875ec12a913a0 Mon Sep 17 00:00:00 2001
From: Oleksandr <maksymets.o@gmail.com>
Date: Tue, 26 Nov 2019 08:12:44 -0800
Subject: [PATCH] Added test coverage measure for habitat-api with codecov
 (#257)

* Added test coverage measure for habitat-api with codecov

* Added codecov badge

* Removed test that caused failures and wasn't runnning as notebooks were removed from repos
---
 .circleci/config.yml         |  3 ++-
 README.md                    |  1 +
 setup.cfg                    |  2 +-
 test/test_relative_camera.py | 40 ------------------------------------
 4 files changed, 4 insertions(+), 42 deletions(-)
 delete mode 100644 test/test_relative_camera.py

diff --git a/.circleci/config.yml b/.circleci/config.yml
index ad0e46f2e..b4c20110e 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -90,7 +90,7 @@ jobs:
                 export PATH=$HOME/miniconda/bin:/usr/local/cuda/bin:$PATH
                 conda create -y -n habitat python=3.6
                 . activate habitat
-                conda install -q -y -c conda-forge ninja ccache numpy pytest pytest-mock
+                conda install -q -y -c conda-forge ninja ccache numpy pytest pytest-mock pytest-cov
               fi
       - run:
           name: Install pytorch
@@ -191,6 +191,7 @@ jobs:
               . activate habitat; cd habitat-api
               python setup.py develop --all
               python setup.py test
+              bash <(curl -s https://codecov.io/bash) -f coverage.xml
 
 
 workflows:
diff --git a/README.md b/README.md
index 9e0882f11..a697fe2bc 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,6 @@
 [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/facebookresearch/habitat-api/blob/master/LICENSE)
 [![CircleCI](https://circleci.com/gh/facebookresearch/habitat-api.svg?style=shield)](https://circleci.com/gh/facebookresearch/habitat-api)
+[![codecov](https://codecov.io/gh/facebookresearch/habitat-api/branch/master/graph/badge.svg)](https://codecov.io/gh/facebookresearch/habitat-api)
 
 Habitat-API
 ==============================
diff --git a/setup.cfg b/setup.cfg
index f856acc6a..28dcb2b4a 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -2,5 +2,5 @@
 test=pytest
 
 [tool:pytest]
-addopts = --verbose -rsxX -q
+addopts = --verbose -rsxX -q --cov-report=xml --cov=./
 testpaths = test
diff --git a/test/test_relative_camera.py b/test/test_relative_camera.py
deleted file mode 100644
index 0911861d4..000000000
--- a/test/test_relative_camera.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/env python3
-
-# Copyright (c) Facebook, Inc. and its affiliates.
-# This source code is licensed under the MIT license found in the
-# LICENSE file in the root directory of this source tree.
-import gc
-
-import pytest
-
-import habitat
-from habitat.datasets.pointnav.pointnav_dataset import PointNavDatasetV1
-
-try:
-    import torch  # noqa # pylint: disable=unused-import
-
-    has_torch = True
-except ImportError:
-    has_torch = False
-
-
-@pytest.mark.skipif(not has_torch, reason="Test needs torch")
-def test_demo_notebook():
-    config = habitat.get_config("configs/tasks/pointnav_rgbd.yaml")
-    config.defrost()
-    config.DATASET.SPLIT = "val"
-
-    if not PointNavDatasetV1.check_config_paths_exist(config.DATASET):
-        pytest.skip("Please download the habitat test scenes")
-    else:
-        pytest.main(
-            [
-                "--nbval-lax",
-                "notebooks/relative_camera_views_transform_and_warping_demo.ipynb",
-            ]
-        )
-
-        # NB: Force a gc collect run as it can take a little bit for
-        # the cleanup to happen after the notebook and we get
-        # a double context crash!
-        gc.collect()
-- 
GitLab