Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add details about running tests locally in CONTRIBUTING.md #655

Merged
merged 2 commits into from
Jan 18, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
# Building and Running Tests Locally

To ensure that the Trace Agent works cross-platform, we use TypeScript build scripts located in the [`scripts`](scripts) directory. The entry point to these scripts is [`index.ts`](scripts/index.ts). The usage of this file is `ts-node -p ./scripts ./scripts/index.ts [command1] [...moreCommands]` (assuming that you are running in the repository root directory.)

The list of possible build commands is enumerated as `case` statements in `index.ts`, in addition to `npm-*` commands. See [`index.ts`](scripts/index.ts) for more details.

`npm run script` is an alias for `ts-node -p ./scripts ./scripts/index.ts`.

For example, to compile all scripts and then initialize test fixtures, the command to use would be one of:

```bash
# Option 1
ts-node -p ./scripts ./scripts/index.ts npm-compile-all init-test-fixtures

# Option 2
npm run script npm-compile-all init-test-fixtures

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.


# Option 3
npm run compile-all
npm run script init-test-fixtures

This comment was marked as spam.

```

They are equivalent.

## Unit Tests

The minimum list of commands needed to run unit tests are:

```bash
npm install
export GCLOUD_TRACE_NEW_CONTEXT=1 # This is required. See cloud-trace-nodejs #650
npm run compile
npm run init-test-fixtures
npm test # Or "npm run script run-unit-tests"
```

A convenient one-liner for this (after `npm install`) is:

```bash
npm install
GCLOUD_TRACE_NEW_CONTEXT=1 npm run script npm-compile-all init-test-fixtures run-unit-tests

This comment was marked as spam.

```

### Why `init-test-fixtures`

The Trace Agent unit tests rely on installing traced modules fixed at distinct version ranges. See [`plugin-fixtures.json`](test/fixtures/plugin-fixtures.json) for the list of fixtures.

# How to become a contributor and submit your own code

## Contributor License Agreements
Expand Down