Changing the test directory in a Clojure/Leiningen project - clojure

I created a new Clojurescript/Om project. The directory structure looks like this:
├── project.clj
├── resources
│   └── public
│   ├── index.html
│   └── src
│   └── om_tutorial
│   └── core.cljs
├── script
│   └── figwheel.clj
├── src
│   ├── clj
│   │   ├── test
│   │   └── example-project
│   │   └── core.clj
│   └── cljs
│   └── example-project
│   └── core.cljs
├── target
│   ├── classes
│   │   └── META-INF
│   │   └── maven
│   │   └── typing
│   │   └── typing
│   │   └── pom.properties
│   └── stale
│   └── leiningen.core.classpath.extract-native-dependencies
└── test
└── clj
└── example-project
└── test_core.clj
My package.json is very minimal, and it looks like this:
(defproject typing "0.1.0-SNAPSHOT"
:description "example-project"
:dependencies [[org.clojure/clojure "1.7.0"]
[org.clojure/clojurescript "1.7.170"]
[org.omcljs/om "1.0.0-alpha22"]
[figwheel-sidecar "0.5.0-SNAPSHOT" :scope "test"]
[http-kit "2.2.0-SNAPSHOT"]
[compojure "1.5.0"]
[ring "1.4.0"]
[cheshire "5.5.0"]]
:test-paths ["test"])
However, I can't get Leiningen to recognize the test path. When I run lein test, I see:
Exception in thread "main" java.io.FileNotFoundException: Could not locate test/typing/test_core__init.class or test/example-project/test_core.clj on classpath. Please check that namespaces with dashes use underscores in the Clojure file name., compiling:(/private/var/folders/dk/jvt798yj6ds6wnkwk_24wrcm0000gp/T/form-init5157365051258208935.clj:1:125)
...
Caused by: java.io.FileNotFoundException: Could not locate test/example-project/test_core__init.class or test/example-project/test_core.clj on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
...
Tests failed.
I moved the tests from test/clj/example-project/... to test/example-project/..., and the implementation from src/clj/example-project/ to src/example-project but I still see the same error.
How do I get Leiningen to recognize my tests?

Perhaps the :test-paths need to reach in further so that source code can be found by lein.
You could try:
:test-paths ["test/clj"]
I see you moved source code around using basically the same thinking. But this is easier. Also after any changes to project.clj you need to lein clean then lein deps. My way is more about the deps and yours more about the clean, but both regardless is expedient. Also you need to check that clean is actually getting rid of output. If it is not you can always manually clean by deleting files.

Related

Running all tests for a multi-binary project

Consider a multi binary project with the following structure.
.
├── bin1
│   ├── config
│   │   ├── config.go
│   │   └── config_test.go
│   └── utils
│   ├── utils.go
│   └── utils_test.go
├── bin2
│   ├── config
│   │   ├── config.go
│   │   └── config_test.go
│   └── utils
│   ├── utils.go
│   └── utils_test.go
├── cmd
│   ├── bin1
│   │   └── bin1.go
│   ├── bin2
│   │   └── bin2.go
│   └── bin3
│   └── bin3.go
├── go.mod
├── go.sum
└── shared
├── db
│   ├── db.go
│   └── db_test.go
├── model
│   ├── modela.go
│   ├── modela_test.go
│   ├── modelb.go
│   └── modelb_test.go
└── utils
├── utils.go
└── utils_test.go
This project has three binaries bin1, bin2 and bin3. Packages in the /shared directory (e.g. package shareddb, sharedmodel and sharedutils) are shared with binary specific packages (e.g. package bin1config, bin1utils in /bin1 directory and package bin2config, bin2utils in /bin2 directory).
How can we run
all the unit tests in this project altogether?
all the tests in a package (e.g. in shared/model)?
each tests separately?
I attempted the following.
Running go test from the project root resulted in no Go files in /projectroot.
# run all tests
go test ./...
# run all tests under a specific directory (including subdiretories)
go test ./bin2/...
# test package located in specific directory
go test ./shared/model
# test package that has specific import path
go test projectroot/shared/model
# test package in current working directory
go test
# ditto
go test .
# test package in parent directory
go test ..
# run a specific test within the package under test
go test -run=X
# run a specific sub-test within the package under test
go test -run=X/Y
For more details on the go test command, see Test packages.
For more details on the [packages] argument to go test, see Packge lists and patters.
For more details on the testing flags, see Testing flags.

Calling the header file in the parent folder

I'm doing some experiments to learn CMake. So the commands stay in my mind. I created a project to test what I just learned. However, I have a problem.
The structure of my project is as follows:
├── bin
├── CMakeLists.txt
└── src
├── Configuration
│   ├── CMakeLists.txt
│   ├── Test
│   │   └── TestConfiguration.h
├── Array
│   └── Array.h
├── CMakeLists.txt
├── Test2
│   ├── CMakeLists.txt
│   ├── Test2.cpp
│   ├── Test2.h
│   └── Test2-1.h
├── Main
│   ├── CMakeLists.txt
│   ├── Config.h
│   └── Main.h
├── Test3
│   ├── CMakeLists.txt
│   ├── Time.h
│   ├── Timer 
│   │   ├── CMakeLists.txt
│   │   ├── Iterate.h
│   │   ├── Run.h
│   │   ├── Serial.cmpl.cpp
│   │   └── Serial.h
│   ├── Smart.h
│   ├── Counting.h
│   ├── Mute.h
│   └── MainTest.h
└── Utilities
├── CMakeLists.txt
├── Inform.h
├── Settings.h
├── Print.h
└── Const.h
But I didn't understand how I should make these CMakeLists.txt files. For example, the file src/Utilities/Inform.h uses the following header:
// src/Utilities/Inform.h
#include "Main/Config.h"
I've tried everything I've seen on the internet and stackoverflow to edit the src/Utilities/CMakeLists.txt file. But no matter what I do, it never sees the Main/Config.h file. I just need to do something like ../../Main/Config.h.
The same problem applies to other folders. What I want to learn here is to be able to navigate and call all files in the project with CMakeLists.txt. While doing this, I tried many of the following parameters:
add_library
target_include_directories
target_link_libraries
link_directories
link_libraries
I think there's something I'm missing or misunderstood. I would be glad if you help me in this regard. If you tell me how to edit the src/Utilities/CMakeLists.txt file, I will try to fill the others accordingly.
Additionally, there is something I'm curious about. Do I also need to edit the src/CMakeLists.txt file? Or is it enough if I just edit for example src/Utilities/CMakeLists.txt?
Also, I don't know if it will be needed additionally, but I'm using cmake version 3.16.3. My development environment is an x86_64 20.04.1 Ubuntu-based Elementary OS.
I've read the official documentation for CMake 3.16 and the answers from fellow developers on StackOverFlow. I want to use the header file in the parent folder in a header in subdirectories. But many ways I've tried are wrong. There is always an error in the include path I entered. I want to learn from experienced developers what I did wrong.

VSCode C++ IntelliSense/autocomplete is not working for OpenCV C++

OpenCV is installed from the source on my Linux (Ubuntu 18.04.6 LTS) machine. The path is a bit different i.e. /usr/local/<blah_blah> and the directory tree looks somewhat like this:
milan#my_machine:/usr/local/<blah_blah>$ tree -L 4
.
├── bin
│   ├── opencv_annotation
│   └── ...
├── include
│   └── opencv4
│   └── opencv2
│   ├── ...
│   ├── core
│   ├── core.hpp
│   ├── ...
│   └── ...
├── lib
│   ├── cmake
│   │   └── opencv4
│   │   ├── OpenCVConfig.cmake
│   │   └── ...
│   ├── ...
│   ├── libopencv_core.so -> libopencv_core.so.4.2
│   ├── libopencv_core.so.4.2 -> libopencv_core.so.4.2.0
│   ├── libopencv_core.so.4.2.0
│   ├── ...
│   ├── ...
│   ├── opencv4
│   │   └── 3rdparty
│   │   ├── ...
│   │   └── ...
│   ├── python2.7
│   │   └── dist-packages
│   │   └── cv2
│   └── python3.6
│   └── dist-packages
│   └── cv2
└── share
├── licenses
│   └── opencv4
│   ├── ...
│   └── ...
└── opencv4
├── ...
│   └── ...
├── ...
└── ...
I had a similar issue for PCL (Point Cloud Library) in the past and my answer/solution fixed that. So, I tried something similar:
In settings.json, I put:
"C_Cpp.default.includePath": [
"/usr/local/<blah_blah>/include/opencv4/opencv2/**",
"/usr/local/<blah_blah>/include/opencv4/opencv2/core",
"/usr/local/<blah_blah>/include/opencv4/opencv2/core/*",
"/usr/local/<blah_blah>/include/opencv4/opencv2/core/**"
],
and in the c_cpp_properties.json file, I put:
"includePath": [
"${workspaceFolder}/**",
"${default}"
],
However, doing this is not fixing the issue. C++ IntelliSense/autocomplete still does not work for OpenCV C++. So, how to fix this issue?
Sample Code:
Note1:
In cmake, /usr/local/<blah_blah>/include/opencv4 is used under include_directories.
Compilation and execution work fine.
Note2: the following questions/issues are different from mine:
VSCode autocomplete not working for OpenCV installed from source -- for OpenCV Python, not C++
cv2 (opencv-python) intellisense not working -- for OpenCV Python, not C++
It turned out that in my settings.json file, the includePaths were set like this:
"C_Cpp.default.includePath": [
"/usr/local/<blah_blah>/include/opencv4/opencv2/**",
"/usr/local/<blah_blah>/include/opencv4/opencv2/core.hpp",
"/usr/local/<blah_blah>/include/opencv4/opencv2/core",
.
.
],
However, in my code, the headers were included like:
#include <opencv2/core.hpp>
If the opencv2 folder needs to be included in the #include directive, the includePaths should look like this:
"C_Cpp.default.includePath": [
"/usr/local/<blah_blah>/include/opencv4",
.
.
],
So, the following includePaths configuration fixed the issue with IntelliSense/autocompletion for OpenCV:
"C_Cpp.default.includePath": [
"/usr/local/<blah_blah>/include/opencv4",
"/usr/local/<blah_blah>/include/opencv4/**",
],
For a detailed explanation, take a look into the issue (Issue 9900) I created on vscode-cpptools GitHub page, particularly this thread/reply.
Special thanks to vscode-cpptools and vscode-cmake-tools team!

Virtualenv for a project with multiple modules

I am trying to build a project from scratch in python 2, it has structure shown below. In past I have created projects with a single hierarchy, so there would be single virtualenv, but this project has multiple subpackages, what is the best practice to be followed: there should be a single virtualenv inside project_root directory shared by all subpackages in it, or there should be separate virtualenv for each subpackage?
project_root/
├── commons
│   ├── hql_helper.py
│   ├── hql_helper.pyc
│   ├── __init__.py
│   └── sample_HQL.hql
├── fl_wtchr
│   ├── fl_wtchr_test.py
│   ├── fl_wtchr_test.pyc
│   ├── __init__.py
│   ├── meta_table.hql
│   ├── requirements.txt
│   ├── sftp_tmp
│   ├── sql_test.py
│   └── sql_test.pyc
├── qry_exec
│   ├── act_qry_exec_script.py
│   ├── hive_db.logs
│   ├── params.py
│   └── params.pyc
├── sqoop_a
│   ├── __init__.py
│   └── sqoop.py
└── test.py
A case could be made for creating separate virtual environments for each module; but fundamentally, you want and expect all this code to eventually be able to run without a virtualenv at all. All your modules should be able to run with whatever you install into the top-level virtual environment and so that's what you should primarily be testing against.

HTMLBars how to get started?

Is there any guide how to start with HTMLBars? I am following "building HTMLBars" section but finally I am stuck. I have run building tool and now I have files in my dist directory like this:
.
├── htmlbars-compiler.amd.js
├── htmlbars-runtime.amd.js
├── morph.amd.js
├── test
│   ├── htmlbars-compiler-tests.amd.js
│   ├── htmlbars-runtime-tests.amd.js
│   ├── index.html
│   ├── loader.js
│   ├── morph-tests.amd.js
│   ├── packages-config.js
│   ├── qunit.css
│   └── qunit.js
└── vendor
├── handlebars.amd.js
└── simple-html-tokenizer.amd.js
Which should I add to my ember project and is that all or have I to do something more? Is this library ready or it is still unusable for ember?
Not even close to ready yet, I'd love to give more info, but there really isn't any. Last I heard they wanted it as a beta in 1.9, but we'll see.