Skip to content

Commit

Permalink
Add script to run code generation for modules containing test types (a…
Browse files Browse the repository at this point in the history
…wakesecurity#16)

* Squash merge from branch `joel-add-compile-proto-file-tool`

* Squash merge from branch `joel-prefer-codegen-over-derive-generic`

* Add proto3-suite-no-tests attr to toplevel

* Add `tests/generate-test-types.sh

* PR feedback from @gabriel re: nix-env invocations and a configure switch in README.md
  • Loading branch information
intractable authored May 30, 2017
1 parent 7c354a1 commit 10f592c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 8 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ and test environment. From the root of this repository:

```bash
$ nix-shell release.nix -A proto3-suite.env
[nix-shell]$ cabal configure --with-gcc=clang --enable-tests
[nix-shell]$ cabal configure --enable-tests
[nix-shell]$ cabal build
[nix-shell]$ cabal test
```
Expand All @@ -43,11 +43,11 @@ Run the following commmand from the root of this repository to install the
`compile-proto-file` executable:

```bash
$ nix-env -iA proto3-suite -f release.nix
$ nix-env --install --attr proto3-suite -f release.nix
```

To remove it from your nix user profile path, use:

```bash
$ nix-env -e proto3-suite
$ nix-env --uninstall proto3-suite
```
7 changes: 4 additions & 3 deletions release.nix
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ let
pkgs = import nixpkgs { inherit config; };

in
{ proto3-suite-linux = linuxPkgs.haskellPackages.proto3-suite;
proto3-suite-darwin = darwinPkgs.haskellPackages.proto3-suite;
proto3-suite = pkgs.haskellPackages.proto3-suite;
{ proto3-suite-linux = linuxPkgs.haskellPackages.proto3-suite;
proto3-suite-darwin = darwinPkgs.haskellPackages.proto3-suite;
proto3-suite = pkgs.haskellPackages.proto3-suite;
proto3-suite-no-tests = pkgs.haskellPackages.proto3-suite-no-tests;
}
2 changes: 1 addition & 1 deletion tests/GeneratedImportedTestTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ instance HsProtobuf.Message WithNesting_Nested where
(HsProtobuf.Prim HsProtobuf.Int32)
(HsProtobuf.Single "nestedField2")
[]
Hs.Nothing)]
Hs.Nothing)]
2 changes: 1 addition & 1 deletion tests/GeneratedTestTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1099,4 +1099,4 @@ instance HsProtobuf.Message Wrapped where
(HsProtobuf.Prim (HsProtobuf.Named (HsProtobuf.Single "Wrapped")))
(HsProtobuf.Single "wrapped")
[]
Hs.Nothing)]
Hs.Nothing)]
14 changes: 14 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Code generation for tests

Running:

```bash
$ bash generate-test-types.sh
```

from inside this directly will result in `GeneratedTestTypes.hs` and
`GeneratedImportedTestTypes.hs` being regenerated from
`../test-files/test.proto` and `../test-files/test_import.proto`, respectively.

We'll eventually `nix`-ify the building of codegen artifacts, so this is a bit
of a stopgap.
3 changes: 3 additions & 0 deletions tests/generate-test-types.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PROTO3_SUITE_NO_TESTS=$(nix-build --no-out-link ../release.nix -A proto3-suite-no-tests)
(cd .. && "${PROTO3_SUITE_NO_TESTS}"/bin/compile-proto-file --proto test-files/test.proto > tests/GeneratedTestTypes.hs)
(cd .. && "${PROTO3_SUITE_NO_TESTS}"/bin/compile-proto-file --proto test-files/test_import.proto > tests/GeneratedImportedTestTypes.hs)

0 comments on commit 10f592c

Please sign in to comment.