Skip to content

Commit c1fe55c

Browse files
szegedirochdev
authored andcommitted
Add an env var for executing integration tests without a sandbox (#5737)
1 parent 57fb569 commit c1fe55c

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

integration-tests/helpers/index.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,23 @@ function spawnProc (filename, options = {}, stdioHandler, stderrHandler) {
145145

146146
async function createSandbox (dependencies = [], isGitRepo = false,
147147
integrationTestsPaths = ['./integration-tests/*'], followUpCommand) {
148-
/* To execute integration tests without a sandbox uncomment the next line
149-
* and do `yarn link && yarn link dd-trace` */
150-
// return { folder: path.join(process.cwd(), 'integration-tests'), remove: async () => {} }
148+
// We might use NODE_OPTIONS to init the tracer. We don't want this to affect this operations
149+
const { NODE_OPTIONS, ...restOfEnv } = process.env
150+
const noSandbox = String(process.env.DD_NO_INTEGRATION_TESTS_SANDBOX)
151+
if (noSandbox === '1' || noSandbox.toLowerCase() === 'true') {
152+
// Execute integration tests without a sandbox. This is useful when you have other components
153+
// yarn-linked into dd-trace and want to run the integration tests against them.
154+
155+
// Link dd-trace to itself, then...
156+
await exec('yarn link')
157+
await exec('yarn link dd-trace')
158+
// ... run the tests in the current directory.
159+
return { folder: path.join(process.cwd(), 'integration-tests'), remove: async () => {} }
160+
}
151161
const folder = path.join(os.tmpdir(), id().toString())
152162
const out = path.join(folder, 'dd-trace.tgz')
153163
const allDependencies = [`file:${out}`].concat(dependencies)
154164

155-
// We might use NODE_OPTIONS to init the tracer. We don't want this to affect this operations
156-
const { NODE_OPTIONS, ...restOfEnv } = process.env
157-
158165
fs.mkdirSync(folder)
159166
const addCommand = `yarn add ${allDependencies.join(' ')} --ignore-engines`
160167
const addOptions = { cwd: folder, env: restOfEnv }

0 commit comments

Comments
 (0)