Discussion:
[dart-misc] pub run test, with transformers, without pub serve?
Daniel Danilatos
2016-04-22 05:58:29 UTC
Permalink
Hi,

I've written a very simple dart -> dart transformer that i'd like to use in
my model code (All "PODO"s) but it would be a shame to have to switch my
currently fast, low-dep, dart-vm, no-browser tests over to relying on
starting up pub serve and running the tests with -p <some browser>.

Is there a way to achieve running the model tests as they used to, i.e.
just plain old "pub run test <some-file>", nice and fast, with just that
simple dart->dart transformer applying?

For clarity, all the transformer does is wrap methods with a particular
annotation in some boilerplate, which to-date we've been writing by hand.

Thanks,
Dan
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Günter Zöchbauer
2016-04-22 09:08:53 UTC
Permalink
AFAIK no, you have to run `pub serve` or `pub build` to get transformers
applied. If this is about server side code then transformers are pointless
because they can't be applied.
There is some infrastructure to test transformers AFAIR but I don't know if
this can be used for your use case. (I think this was in the barback
package.)
An alternative is the new build <https://github.com/dart-lang/build> package
but it's rather to generate new code instead of modifying existing one.
Post by Daniel Danilatos
Hi,
I've written a very simple dart -> dart transformer that i'd like to use
in my model code (All "PODO"s) but it would be a shame to have to switch my
currently fast, low-dep, dart-vm, no-browser tests over to relying on
starting up pub serve and running the tests with -p <some browser>.
Is there a way to achieve running the model tests as they used to, i.e.
just plain old "pub run test <some-file>", nice and fast, with just that
simple dart->dart transformer applying?
For clarity, all the transformer does is wrap methods with a particular
annotation in some boilerplate, which to-date we've been writing by hand.
Thanks,
Dan
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Daniel Danilatos
2016-04-22 10:33:03 UTC
Permalink
Perhaps is there just a way to run the build or just the transformer and
have it dump to some output dir, and run the tests from there? I found
this:
http://stackoverflow.com/questions/22386070/turn-off-dart2js-during-pub-build
but it seems fairly hacky.

This is "model" code, which in my case happens to ultimately be client
side, but I don't see why it couldn't be server side. Why would
transformers be pointless for this use case? Or do you mean pointless in
the practical sense, because the only current way to apply transformers is
through pub.

I considered writing my transformer in a way that it would generate
separate classes instead, but that would require many more code changes.
Right now it's a transparent drop-in. Also, more severely, if I were to
output separate files, then they would not be visible in the editor, so I'd
have all kinds of spurious errors and warnings.

Are transformers not meant to be used for dart code, but rather just
resources like css, templates etc? Am I doing something contrary to the
philosophy here? I considered transformers to be somewhat analogous to
webpack's loaders, which are extremely powerful (I guess transformers don't
hook into the module loading system).

Dan
Post by Günter Zöchbauer
AFAIK no, you have to run `pub serve` or `pub build` to get transformers
applied. If this is about server side code then transformers are pointless
because they can't be applied.
There is some infrastructure to test transformers AFAIR but I don't know
if this can be used for your use case. (I think this was in the barback
package.)
An alternative is the new build <https://github.com/dart-lang/build> package
but it's rather to generate new code instead of modifying existing one.
Post by Daniel Danilatos
Hi,
I've written a very simple dart -> dart transformer that i'd like to use
in my model code (All "PODO"s) but it would be a shame to have to switch my
currently fast, low-dep, dart-vm, no-browser tests over to relying on
starting up pub serve and running the tests with -p <some browser>.
Is there a way to achieve running the model tests as they used to, i.e.
just plain old "pub run test <some-file>", nice and fast, with just that
simple dart->dart transformer applying?
For clarity, all the transformer does is wrap methods with a particular
annotation in some boilerplate, which to-date we've been writing by hand.
Thanks,
Dan
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Günter Zöchbauer
2016-04-22 11:47:21 UTC
Permalink
Post by Daniel Danilatos
Perhaps is there just a way to run the build or just the transformer and
have it dump to some output dir, and run the tests from there? I found
http://stackoverflow.com/questions/22386070/turn-off-dart2js-during-pub-build
but it seems fairly hacky.
This is "model" code, which in my case happens to ultimately be client
side, but I don't see why it couldn't be server side. Why would
transformers be pointless for this use case?
Or do you mean pointless in the practical sense, because the only current
way to apply transformers is through pub.
That's exactly what I meant.
Post by Daniel Danilatos
I considered writing my transformer in a way that it would generate
separate classes instead, but that would require many more code changes.
Right now it's a transparent drop-in. Also, more severely, if I were to
output separate files, then they would not be visible in the editor, so I'd
have all kinds of spurious errors and warnings.
Are transformers not meant to be used for dart code, but rather just
resources like css, templates etc? Am I doing something contrary to the
philosophy here? I considered transformers to be somewhat analogous to
webpack's loaders, which are extremely powerful (I guess transformers don't
hook into the module loading system).
Dan
Transformers are meant to be used for dart code but the server-side is just
not covered.
For Dart transformers are for example used to generate code to replace
'dart:mirrors' which is mandatory for client-side code but doesn't matter
much for server side code.
There are many interesting use cases as well (like
AOP/cross-cutting-concerns) but not everything that is nice and useful has
already been implemented, otherwise the Dart team could be re-purposed for
other tasks ;-)
Post by Daniel Danilatos
Post by Günter Zöchbauer
AFAIK no, you have to run `pub serve` or `pub build` to get transformers
applied. If this is about server side code then transformers are pointless
because they can't be applied.
There is some infrastructure to test transformers AFAIR but I don't know
if this can be used for your use case. (I think this was in the barback
package.)
An alternative is the new build <https://github.com/dart-lang/build> package
but it's rather to generate new code instead of modifying existing one.
Post by Daniel Danilatos
Hi,
I've written a very simple dart -> dart transformer that i'd like to use
in my model code (All "PODO"s) but it would be a shame to have to switch my
currently fast, low-dep, dart-vm, no-browser tests over to relying on
starting up pub serve and running the tests with -p <some browser>.
Is there a way to achieve running the model tests as they used to, i.e.
just plain old "pub run test <some-file>", nice and fast, with just that
simple dart->dart transformer applying?
For clarity, all the transformer does is wrap methods with a particular
annotation in some boilerplate, which to-date we've been writing by hand.
Thanks,
Dan
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Natalie Weizenbaum' via Dart Misc
2016-04-22 20:47:17 UTC
Permalink
You do have to run pub serve or pub build to use test with transformed
code. However, you *don't* need to run your tests in a browser. If you run pub
run test --pub-serve=8080, it will run VM tests against your transformed
code.
Post by Daniel Danilatos
Hi,
I've written a very simple dart -> dart transformer that i'd like to use
in my model code (All "PODO"s) but it would be a shame to have to switch my
currently fast, low-dep, dart-vm, no-browser tests over to relying on
starting up pub serve and running the tests with -p <some browser>.
Is there a way to achieve running the model tests as they used to, i.e.
just plain old "pub run test <some-file>", nice and fast, with just that
simple dart->dart transformer applying?
For clarity, all the transformer does is wrap methods with a particular
annotation in some boilerplate, which to-date we've been writing by hand.
Thanks,
Dan
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Daniel Danilatos
2016-04-23 07:46:35 UTC
Permalink
Hmm, for some reason it's not working unless I add "-p chrome" or similar.
There's errors in the pub serve console, regarding one of the files
imported from the test, saying "[test] GET web/foo/foo.dart → Could not
find asset Client|test/web/foo/foo.dart." Possibly related to a mistake I
made early in the project and put all the code inside the the web/ folder
instead of lib/? Though I don't clearly understand why it should work fine
with "-p chrome" and not without it. (I just assumed I'd have to use the
browser). I suppose I should move most if not all the code into lib/ ?
(Hard to do when others have uncommitted changes!)

On Sat, Apr 23, 2016 at 4:47 AM 'Natalie Weizenbaum' via Dart Misc <
Post by 'Natalie Weizenbaum' via Dart Misc
You do have to run pub serve or pub build to use test with transformed
code. However, you *don't* need to run your tests in a browser. If you
run pub run test --pub-serve=8080, it will run VM tests against your
transformed code.
Post by Daniel Danilatos
Hi,
I've written a very simple dart -> dart transformer that i'd like to use
in my model code (All "PODO"s) but it would be a shame to have to switch my
currently fast, low-dep, dart-vm, no-browser tests over to relying on
starting up pub serve and running the tests with -p <some browser>.
Is there a way to achieve running the model tests as they used to, i.e.
just plain old "pub run test <some-file>", nice and fast, with just that
simple dart->dart transformer applying?
For clarity, all the transformer does is wrap methods with a particular
annotation in some boilerplate, which to-date we've been writing by hand.
Thanks,
Dan
--
Post by Daniel Danilatos
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Erik Ernst' via Dart Misc
2016-04-23 10:25:53 UTC
Permalink
About the specific issue of transforming Dart code and running it on the
vm: For a suitable `foo`, you can use `pub build --mode=debug foo` to
obtain transformed Dart code in `build/foo` and then run it with the vm
using `--package-root=build/foo/packages` (and if you don't need the
JavaScript output then you may wish to disable the `$dart2js` transformer
with a `$include: []` in pubspec.yaml).
Post by Daniel Danilatos
Hmm, for some reason it's not working unless I add "-p chrome" or
similar. There's errors in the pub serve console, regarding one of the
files imported from the test, saying "[test] GET web/foo/foo.dart → Could
not find asset Client|test/web/foo/foo.dart." Possibly related to a
mistake I made early in the project and put all the code inside the the
web/ folder instead of lib/? Though I don't clearly understand why it
should work fine with "-p chrome" and not without it. (I just assumed I'd
have to use the browser). I suppose I should move most if not all the code
into lib/ ? (Hard to do when others have uncommitted changes!)
On Sat, Apr 23, 2016 at 4:47 AM 'Natalie Weizenbaum' via Dart Misc <
Post by 'Natalie Weizenbaum' via Dart Misc
You do have to run pub serve or pub build to use test with transformed
code. However, you *don't* need to run your tests in a browser. If you
run pub run test --pub-serve=8080, it will run VM tests against your
transformed code.
Post by Daniel Danilatos
Hi,
I've written a very simple dart -> dart transformer that i'd like to use
in my model code (All "PODO"s) but it would be a shame to have to switch my
currently fast, low-dep, dart-vm, no-browser tests over to relying on
starting up pub serve and running the tests with -p <some browser>.
Is there a way to achieve running the model tests as they used to, i.e.
just plain old "pub run test <some-file>", nice and fast, with just that
simple dart->dart transformer applying?
For clarity, all the transformer does is wrap methods with a particular
annotation in some boilerplate, which to-date we've been writing by hand.
Thanks,
Dan
--
Post by Daniel Danilatos
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to
http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google
Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
Erik Ernst - Google Danmark ApS
Skt Petri Passage 5, 2 sal, 1165 KÞbenhavn K, Denmark
CVR no. 28866984
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Loading...