Dart test coverage not showing up for lib files - dart

How do you make coverage reports include those in under lib directory? Right now when I run tests with dart test --coverage="coverage", it will only record coverage on my test files and not on the lib files. But when I change the imports declaration for my lib files relatively like:
import '../../lib/conventional.dart';
...instead of:
import 'package:conventional/conventional.dart';
...it works. Maybe I'm doing something wrong? Dart version is Dart SDK version: 2.12.0 (stable) on "linux_x64" and coverage version is 1.0.1. The source code can be found here: https://github.com/asartalo/conventional/

I asked the question on reddit and got an answer there. So after running dart test --coverage="coverage", I needed to add --packages=.packages as in:
dart test --coverage="coverage"
format_coverage --lcov --in=coverage --out=coverage.lcov --packages=.packages --report-on=lib
Before, I didn't include the --packages=.packages option and so it was only showing coverage for the test files. The documentation for this said:
--packages path to the package spec file
..and didn't mention anything about the significance of that. It's been frustrating.

Related

Dart import a package you have created

I have some code that i want to use between two projects. I would like to break this out into a package and import it into other projects/packages that need it. When i try to import a locally created package, I get a "The target URI doesnt exist" error. What do i need to do? Is there a path environment variable that dart checks to find local packages? Do i need to publish my package to pub.dev and use "dart pub add"? (I really would not prefer this)
Thanks in advance
The dependencies section of pubspec.yaml supports, along with the pub.dev and Git options, a path option.
Path dependencies are documented on the Dart website.
For example:
dependencies:
hosted_package: ^1.0.0
local_package:
path: ../my_local_package

Cocos2d - json/document.h file not found

I create a mobile game using cocos2d framework. The problem is I got this error when I try to compile ios platform.
In file included from /Users/MNurdin/Documents/Game/WTP/frameworks/js-bindings/bindings/manual/chipmunk/js_bindings_chipmunk_manual.cpp:26:
In file included from /Users/MNurdin/Documents/Game/WTP/frameworks/js-bindings/bindings/proj.ios_mac/../../cocos2d-x/extensions/cocos-ext.h:16:
In file included from /Users/MNurdin/Documents/Game/WTP/frameworks/js-bindings/bindings/proj.ios_mac/../../cocos2d-x/extensions/assets-manager/AssetsManager.h:32:
/Users/MNurdin/Documents/Game/WTP/frameworks/js-bindings/bindings/proj.ios_mac/../../cocos2d-x/extensions/assets-manager/Manifest.h:36:10: fatal error: 'json/document.h' file not found
#include "json/document.h"
I follow exactly this tutorial from A- Z. I run this command in my terminal to compile my project.
cocos compile -p ios
Reference: http://cocos2d-x.org/docs/manual/framework/html5/v2/cocos-console/en
This is only an issue if you are using the source code from github.
I assume you are missing extra step required when you got the project from github.
In ReadMe it says:
Github note
If you fork our github repository or download the package from github,
you will need to do some extra tasks:
Run frameworks/js-bindings/cocos2d-x/download-deps.py to download external dependencies for Cocos2d-x
Run tools/cocos2d-console/download-bin.py to download bin files for some cocos2d-console plugins like Google Closure Compiler and JSC
Compiler.
It looks like the subproject is completely missing json/document.h file as referenced in Manifest.h. I attempted a simple comment of the include, but this raised errors I believe related to the missing header. I think filing a bug related to this subproject (Cocos2d_libs) is in order.

Dart web application can not import local package

I have developed a simple library (called picasawebalbums) that I wish to import in another web application.
I have added the the following to pubspect.yaml
picasawebalbums:
path: C:\Users\hangs_000\Documents\GitHub\PicasaWebAlbums
But the package does not appear under the 'packages' directory and of course my dart code cannot import any of the classes.
I feel that I have missed out a step somewhere.
Try pub get --verbose or pub upgrade --verbose from command line in your application directory and look at the output. You can try without --verbose first. This prints much less but may offer a hint anywhere.

Failed to load package in Dart

When I try to import a package with the syntax import 'package:markdown/markdown.dart';, I get no error in Dart Editor but when I run the dart application, the debugger shows me the message:
An error occurred loading file: package:markdown/markdown.dart
Failed to load resource
chrome-extension://gfjabgeipkcfopofkhjimepepnomcidk/dart/packages/markdown/markdown.dart
But when I write the whole path (import "../../packages/markdown/markdown.dart";) everything works fine. I cannot understand why the syntax package: doesn't work in my code though it works in Dart Editor's own examples.
You can see the Chrome app architecture below (I'm loading a package from translator.dart):
You should have the package added as a dependency in pubspec.yaml (which I assume you do).
Also try running following:
delete packages folder
delete pubspec.lock
run pub get to fetch the
dependencies again.
I think in your md_to_html folder you need a link to the 'packages' directory for the shortform to work. I seem to remember this happening when the workspace is built but I'm not sure now which command triggers it, have a look at the current pub docs.

pubspec.yaml deprecated layout

Here is my pubspec.yaml.
name: oct
version: 0.1.0
description: >
Ojus Chemistry Toolkit (OCT) is an open-source toolkit for solving a
variety of cheminformatics problems. It is developed in Dart, mostly.
dependencies:
args:
sdk: args
When I run pub install, I receive a warning as follows.
Warning: Package "oct" is using a deprecated layout.
Reading pub's package layout details, I have not yet understood what is triggering the above warning. Request help! Thanks!
Most likely, you have some .dart files outside predefined directories:
lib
web
test
New SDK gives a helpful link if this problem occurs: http://www.dartlang.org/docs/pub-package-manager/package-layout.html
Lesiak is mostly right. You'll get this warning if pub finds any .dart files in your package's root directory. In the old layout, that was where you put your publicly importable files.
In the new layout, those should go under lib.

Resources