Skip to content

added examples and py utils - #159

Merged
sbinet merged 14 commits into
go-python:masterfrom
drew-512:add-examples
Feb 12, 2022
Merged

added examples and py utils#159
sbinet merged 14 commits into
go-python:masterfrom
drew-512:add-examples

Conversation

@drew-512

Copy link
Copy Markdown
Contributor

No description provided.

@codecov

codecovBot commented Feb 7, 2022

Copy link
Copy Markdown

Codecov Report

Merging #159 (c67547f) into master (727b7c4) will decrease coverage by 1.43%.
The diff coverage is 10.36%.

Impacted file tree graph

@@ Coverage Diff @@## master #159 +/- ##
==========================================
- Coverage 74.40% 72.96% -1.44% 
==========================================
Files 66 70 +4 Lines 11395 11647 +252 ==========================================
+ Hits 8478 8498 +20 - Misses 2351 2583 +232 
Partials 566 566 
Impacted FilesCoverage Δ
examples/embedding/main.go0.00% <0.00%> (ø)
py/util.go0.00% <0.00%> (ø)
examples/embedding/mylib.module.go32.25% <32.25%> (ø)
repl/cli/cli.go0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 727b7c4...c67547f. Read the comment docs.

@sbinetsbinet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good.

but could we find a way to wire the examples into either a func ExampleXXX or func TestXXX scaffolding?
so everything is tested w/ go test ./...?
(I guess func TestXXX would be easier)

@drew-512

Copy link
Copy Markdown
ContributorAuthor

I had that thought as well. If I make the example's main optionally output to a file, in the TestXXX variant I could just compare that output against a known output as the test. How does that sound?

@sbinet

Copy link
Copy Markdown
Member

yes, that, or have everything being compiled as part of the func TestXXX:

  • compile the main package,
  • run the output executable with os/exec.Command,
  • capture stdout/stderr and
  • compare with some reference.
    we did something along these lines for go-python/gopy

@drew-512

Copy link
Copy Markdown
ContributorAuthor

How does this look? I'm not well versed in this sort of stuff, so lmk what I'm missing, thanks.

@drew-512

Copy link
Copy Markdown
ContributorAuthor

@sbinet This works on my setup but it looks like I need help getting it work with CI here.

@sbinet

sbinet commented Feb 12, 2022

Copy link
Copy Markdown
Member

it probably is coming from this:

=== RUN TestEmbeddedExample
main_test.go:64: could not run diff command: exit status 1
main_test.go:66: test output differ:
--- testdata/embedding_golden.txt	2022-02-12 14:36:59.468987820 +0100
+++ /tmp/go-python-embedding-181936362/out.txt	2022-02-12 14:50:15.575695331 +0100
@@ -4,7 +4,7 @@
==========================================================
Python 3.4 (github.com/go-python/gpython)
- go1.17.6 on darwin amd64
+ devel go1.18-a5c0b19080 Sun Jan 30 02:29:51 2022 +0000 on linux amd64
==========================================================
Spring Break itinerary:
--- FAIL: TestEmbeddedExample (0.50s)
FAIL
FAIL	github.com/go-python/gpython/examples/embedding	0.507s
FAIL

Comment threadexamples/embedding/main_test.go Outdated
Comment threadexamples/embedding/main_test.go Outdated
Comment threadexamples/embedding/main_test.go Outdated
Comment threadexamples/embedding/main_test.go Outdated
Comment threadexamples/embedding/main_test.go
Comment threadexamples/embedding/mylib.module.go Outdated
drew-512and others added 8 commits February 12, 2022 09:58
Co-authored-by: Sebastien Binet <binet@cern.ch>
Co-authored-by: Sebastien Binet <binet@cern.ch>
Co-authored-by: Sebastien Binet <binet@cern.ch>
Co-authored-by: Sebastien Binet <binet@cern.ch>
Co-authored-by: Sebastien Binet <binet@cern.ch>
Co-authored-by: Sebastien Binet <binet@cern.ch>
@drew-512

Copy link
Copy Markdown
ContributorAuthor

Sigh, so I guess windows needed to be exe.exe? I test for windows at runtime and append an ".exe"?

Comment threadexamples/embedding/lib/mylib.py Outdated
Comment threadexamples/embedding/main_test.go Outdated
Comment threadexamples/embedding/main_test.go Outdated
drew-512and others added 3 commits February 12, 2022 10:45
Co-authored-by: Sebastien Binet <binet@cern.ch>
Co-authored-by: Sebastien Binet <binet@cern.ch>
Co-authored-by: Sebastien Binet <binet@cern.ch>
@drew-512

Copy link
Copy Markdown
ContributorAuthor

yay!

@sbinetsbinet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sbinet
sbinet merged commit 7f55cd3 into go-python:masterFeb 12, 2022
@sbinetsbinet mentioned this pull request Feb 13, 2022
@drew-512
drew-512 deleted the add-examples branch February 17, 2022 02:04
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@drew-512@sbinet