{"action":"created","issue":{"url":"https://api.github.com/repos/grumpyhome/grumpy/issues/55","repository_url":"https://api.github.com/repos/grumpyhome/grumpy","labels_url":"https://api.github.com/repos/grumpyhome/grumpy/issues/55/labels{/name}","comments_url":"https://api.github.com/repos/grumpyhome/grumpy/issues/55/comments","events_url":"https://api.github.com/repos/grumpyhome/grumpy/issues/55/events","html_url":"https://github.com/grumpyhome/grumpy/issues/55","id":352358428,"node_id":"MDU6SXNzdWUzNTIzNTg0Mjg=","number":55,"title":"Python tests does not count over `make cover`","user":{"login":"alanjds","id":155623,"node_id":"MDQ6VXNlcjE1NTYyMw==","avatar_url":"https://avatars3.githubusercontent.com/u/155623?v=4","gravatar_id":"","url":"https://api.github.com/users/alanjds","html_url":"https://github.com/alanjds","followers_url":"https://api.github.com/users/alanjds/followers","following_url":"https://api.github.com/users/alanjds/following{/other_user}","gists_url":"https://api.github.com/users/alanjds/gists{/gist_id}","starred_url":"https://api.github.com/users/alanjds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alanjds/subscriptions","organizations_url":"https://api.github.com/users/alanjds/orgs","repos_url":"https://api.github.com/users/alanjds/repos","events_url":"https://api.github.com/users/alanjds/events{/privacy}","received_events_url":"https://api.github.com/users/alanjds/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-08-21T02:06:51Z","updated_at":"2018-08-21T02:06:59Z","closed_at":null,"author_association":"NONE","body":"## History:\r\n\r\nAs said in the discussion starting on https://github.com/google/grumpy/pull/243#issuecomment-292009268, the Python tests does not count over `make cover` report.\r\n\r\nPersonally, this hinders the development speed by forcing people to write tests twice: one for Python (what we _want_ working) and one for Golang (what we _need_  to count on `make cover`).\r\n\r\nThe hypothesis is: Lowering the work needed to push code, more code will be pushed by more people.\r\n\r\nLets fix it to speed up the development!\r\n\r\n## Plan:\r\n\r\n- [x] Change `grumpc` to be able to produce `module_test.go` output from Python test files\r\n- [ ] Make the `make test` to produce `module_test.go` files from `grumpy/testing/*.py` files\r\n- [ ] Make the produced `module_test.go` files to be in such place that counts for coverage\r\n- [ ] Write a change in a runtime `.go` file. Write a test the for the change in a `.py`\r\n- [ ] Check that `make cover` counts the `.py` covering the `.go` changed"},"comment":{"url":"https://api.github.com/repos/grumpyhome/grumpy/issues/comments/414525875","html_url":"https://github.com/grumpyhome/grumpy/issues/55#issuecomment-414525875","issue_url":"https://api.github.com/repos/grumpyhome/grumpy/issues/55","id":414525875,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNDUyNTg3NQ==","user":{"login":"alanjds","id":155623,"node_id":"MDQ6VXNlcjE1NTYyMw==","avatar_url":"https://avatars3.githubusercontent.com/u/155623?v=4","gravatar_id":"","url":"https://api.github.com/users/alanjds","html_url":"https://github.com/alanjds","followers_url":"https://api.github.com/users/alanjds/followers","following_url":"https://api.github.com/users/alanjds/following{/other_user}","gists_url":"https://api.github.com/users/alanjds/gists{/gist_id}","starred_url":"https://api.github.com/users/alanjds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alanjds/subscriptions","organizations_url":"https://api.github.com/users/alanjds/orgs","repos_url":"https://api.github.com/users/alanjds/repos","events_url":"https://api.github.com/users/alanjds/events{/privacy}","received_events_url":"https://api.github.com/users/alanjds/received_events","type":"User","site_admin":false},"created_at":"2018-08-21T02:06:59Z","updated_at":"2018-08-21T02:06:59Z","author_association":"NONE","body":"<a href=\"https://github.com/alanjds\"><img src=\"https://avatars3.githubusercontent.com/u/155623?v=4\" align=\"left\" width=\"48\" height=\"48\" hspace=\"10\"></img></a> **Comment by [alanjds](https://github.com/alanjds)**\n_Friday Nov 10, 2017 at 01:39 GMT_\n\n----\n\nFrom a Python file containing `print 'Hello World!'`, `grumpc` does produce this `module.go`:\r\n```go\r\npackage __main__\r\nimport πg \"grumpy\"\r\nvar Code *πg.Code\r\nfunc init() {\r\n        Code = πg.NewCode(\"<module>\", \"print_hello.py\", nil, 0, func(πF *πg.Frame, _ []*πg.Object) (*πg.Object, *πg.BaseException) {\r\n                var πR *πg.Object; _ = πR\r\n                var πE *πg.BaseException; _ = πE\r\n                var πTemp001 []*πg.Object\r\n                _ = πTemp001\r\n                for ; πF.State() >= 0; πF.PopCheckpoint() {\r\n                        switch πF.State() {\r\n                        case 0:\r\n                        default: panic(\"unexpected function state\")\r\n                        }\r\n                        // line 1: print 'Hello World!'\r\n                        πF.SetLineno(1)\r\n                        πTemp001 = make([]*πg.Object, 1)\r\n                        πTemp001[0] = πg.NewStr(\"Hello World!\").ToObject()\r\n                        if πE = πg.Print(πF, πTemp001, true); πE != nil {\r\n                                continue\r\n                        }\r\n                }\r\n                return nil, πE\r\n        })\r\n        πg.RegisterModule(\"__main__\", Code)\r\n}\r\n```\r\n\r\nI managed to add a flag to `grumpc` that, for the same Python input, produces:\r\n\r\n```go\r\npackage __main__\r\nimport πg \"grumpy\"\r\nimport πt \"testing\"\r\nvar Code *πg.Code\r\nfunc init() {\r\n        Code = πg.NewCode(\"<module>\", \"print_hello.py\", nil, 0, func(πF *πg.Frame, _ []*πg.Object) (*πg.Object, *πg.BaseException) {\r\n                var πR *πg.Object; _ = πR\r\n                var πE *πg.BaseException; _ = πE\r\n                var πTemp001 []*πg.Object\r\n                _ = πTemp001\r\n                for ; πF.State() >= 0; πF.PopCheckpoint() {\r\n                        switch πF.State() {\r\n                        case 0:\r\n                        default: panic(\"unexpected function state\")\r\n                        }\r\n                        // line 1: print 'Hello World!'\r\n                        πF.SetLineno(1)\r\n                        πTemp001 = make([]*πg.Object, 1)\r\n                        πTemp001[0] = πg.NewStr(\"Hello World!\").ToObject()\r\n                        if πE = πg.Print(πF, πTemp001, true); πE != nil {\r\n                                continue\r\n                        }\r\n                }\r\n                return nil, πE\r\n        })\r\n        πg.RegisterModule(\"__main__\", Code)\r\n}\r\nfunc TestRunCode(t *testing.T) {\r\n        init()\r\n        πg.ImportModule(grumpy.NewRootFrame(), \"traceback\")\r\n        //πg.ImportModule(grumpy.NewRootFrame(), \"__main__\")\r\n        πg.RunMain(Code)\r\n}\r\n```\r\nto be saved as `module_test.go`\n"}}
{"actor":{"display_login":"alanjds"}}