KUSHAGRA BANSAL
KUSHAGRA BANSAL

Reputation: 95

How to test my script in a github repo which is dependent upon other files in the repo

In my github repository, I have a python script say script.py. I want to check if this produces the desired output or not?
I can copy the code of this file ad run it on my local machine but this script.py is using functions and modules from other files in the repository as well. So I cannot simply copy script.py and run it to test it.

So what should I do? How do I make sure that this produces the right output?

I am very new to git and VC so please answer elaborately.

Upvotes: 0

Views: 650

Answers (2)

cschenio
cschenio

Reputation: 107

It depends on what you want to do.

First, try to think GitHub as a place only to put your code, without any other functionalities (which actually is not the case). So if you want to run a script script.py and it depends on other files in the same repo, then you have to download at least itself and the files it depends on, more easily just download the entire repo. This is also the easiest way since if there are updates in the remote repo, you can pull the change to your local repo. It guarantees you have the same content between remote and local.

And yes, there are other ways. Like @yflelion said, you can try travis CI (or any CI). Think of CI being some program runners, and once you have some code changes it will run though some pre-defined code and make sure all of them are correct. This approach leads you into the concept of software testing and DevOps. It requires a lot more work than just simply clone the repo and run, but it is automated and can assure the code quality through an intensive and long developing process of a product.

BTW just out of curiosity, why are you trying not to clone the repository? Is there any non-trivial reason?

Upvotes: 1

yflelion
yflelion

Reputation: 1746

why you don't clone your repository and run your script?

Upvotes: 1

Related Questions