How to run tests with Dart 2.0 preview - dart

I'm using the Dart SDK in the latest install of Flutter:
Dart VM version: 2.0.0-dev.43.0.flutter-52afcba357 (Fri Mar 30 20:33:12 2018 +0000) on "windows_x64"
I can run individual tests with Dart 2.0 (now in preview) by using the --preview-dart-2 command-line argument, e.g:
$ dart --preview-dart-2 test\my_test.dart
But is it possible to run all tests with Dart 2.0, e.g:
$ pub run test
This only runs the test suite as Dart 1.x which doesn't seem to accept the --preview-dart-2 flag.

pub run doesn't support --preview-dart-2 yet and I'm sure pub test depends on pub run.
There is an open issue Implement --preview-dart-2 option for pub run #1807

Related

Having problems with imports in dart 2.17 in vscode

I'm having problems with VS Code not able to find packages after updating to dart 2.17. This worked fine while using dart 2.16.
With the following dart file:
import 'package:test/test.dart';
...
And the following pubspec.yaml
dev_dependencies:
test: ^1.17.4
VSCode is showing that there's a problem:
Target of URI doesn't exist: 'package:test/test.dart'.
Try creating the file referenced by the URI, or Try using a URI for a file that does exist.
The project can be run from CLI fine, just that VS Code IDE is showing issues to resolve.
This is using:
VSCode Version: 1.67.2
Dart extension in VSCode: v3.40.0
macOS 12.4
Dart SDK version: 2.17.1 (stable) (Tue May 17 17:58:21 2022 +0000) on "macos_arm64"
Note: This is a pure dart project, no flutter libraries are installed/used.

How does bazel choose the python version?

I'm running a python binary target with bazel run xxx and in the target I'm doing print(sys.version). This outputs Python version 3.6.8 (default, Jan 14 2019, 11:02:34)
When I type the python command directly, I get Python 3.7.3 (default, Apr 3 2019, 19:16:38)
Why/how did bazel choose a different python version?
Bazel will choose different python versions based on the configuration of the build. If nothing is overriden, bazel will use its default python version. This can be overridden by passing --python_version=<some_version> when running a bazel command.
https://docs.bazel.build/versions/master/be/python.html#py_binary.python_version
https://github.com/bazelbuild/rules_python/blob/120590e2f2b66e5590bf4dc8ebef9c5338984775/python/BUILD#L43

Can't run Dart 2 command line programs

I am trying to write a simple command line program with Dart 2. I have used Dart 2 before with Flutter without any problems, but when trying to run my command line application, I can't get it to work.
I am getting the following error:
NoSuchMethodError: Attempted to use type '_Testtt' as a function. Since types do not define a method 'call', this is not possible. Did you intend to call the _Testtt constructor and forget the 'new' operator?
Receiver: _Testtt
I am confident that nothing is wrong with my class. Also, in VS Code, it recognizes that it is in fact a constructor.
I am using the Dart version that ships with Flutter.
Does any one have an idea?
Dart Version:
Dart VM version: 2.0.0-dev.59.0.flutter-ff815d05a5 (Tue May 29 20:01:09 2018 +0000) on "windows_x64"
pubspec:
environment:
sdk: '>=2.0.0-dev.55.0 <2.0.0'
dependencies:
http: "^0.11.3+16"
dev_dependencies:
test: ^0.12.30
Don't use the modified flutter SDK for normal Dart programs. Download the regular SDK (albeit the dev channel - currently 2.0.0-dev.60.0) and install it somewhere away from your flutter installation. Use this SDK for non-Flutter Dart programs.
There's a command line argument that you need to turn on to get the regular Dart SDK to support the new 2.0 features like optional new. When running from the command line specify --preview-dart-2.

Deploying snapshot application in sourcevoid results in "Wrong script snapshot version, expected '...' found '...'

Some applications require deploying a snapshot to sourcevoid (see How do I deploy application on sourcevoid with private git package dependencies?). When deploying such application, I received the error:
Wrong script snapshot version, expected '181c54397e255f0b57b3cbca6f22607a' found '67ac118c5ca5a680109da82693316e0c'
Make sure your sourcevoid.yaml version matches the version of dart on the machine used to build the snapshot. For those starting out with dart, you can find the version of dart in your favorite terminal by typing:
$ dart --version
Dart VM version: 1.17.1 (Fri Jun 10 04:46:03 2016) on "macos_x64"
Match the n.n.n number showing in the version output in your sourcevoid.yaml as shown below:
sourcevoid.yaml:
runtime: dart
version: 1.17.1
start: dart path/to/snapshot

Installing Dart Editor in Debian

How to exactly install dart editor in debian? Tried to build dart from the source on this site Building Dart on Debian up to the gclient runhooks and ran
$ cd dart
$ ./tools/build.py -m release -a x64
which they say will build ALL (including the dart editor w/c I prefer). But unluckily, the build fails after waiting a thousand years. Any ideas on how to properly install ALL the dart components on debian?
I tried a while ago and failed building Dartium on Debian.
It might make sense to build the Dart runtime you use for the production server yourself but IMHO building DartEditor and Dartium is not worth the effort on Debian.
To install the development environment I just download the Linux package and unpack it.

Resources