2019-01-06 09:45:06 -05:00
|
|
|
/******************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2017, the Perspective Authors.
|
|
|
|
|
*
|
|
|
|
|
* This file is part of the Perspective library, distributed under the terms of
|
|
|
|
|
* the Apache License 2.0. The full license can be found in the LICENSE file.
|
|
|
|
|
*
|
|
|
|
|
*/
|
2021-09-12 14:08:32 -04:00
|
|
|
const {
|
|
|
|
|
bash,
|
|
|
|
|
execute,
|
|
|
|
|
execute_throw,
|
|
|
|
|
docker,
|
|
|
|
|
resolve,
|
|
|
|
|
getarg,
|
|
|
|
|
python_image,
|
|
|
|
|
} = require("./script_utils.js");
|
2019-01-06 09:45:06 -05:00
|
|
|
|
2021-10-23 01:29:39 -04:00
|
|
|
let PYTHON = getarg("--python38")
|
2021-09-12 14:08:32 -04:00
|
|
|
? "python3.8"
|
2021-10-23 01:29:39 -04:00
|
|
|
: getarg("--python36")
|
|
|
|
|
? "python3.6"
|
|
|
|
|
: getarg("--python37")
|
|
|
|
|
? "python3.7"
|
|
|
|
|
: "python3";
|
2020-06-16 17:49:30 -04:00
|
|
|
|
|
|
|
|
const COVERAGE = getarg("--coverage");
|
2020-03-12 13:10:45 -04:00
|
|
|
const VERBOSE = getarg("--debug");
|
2020-06-22 10:15:40 -04:00
|
|
|
const IS_DOCKER = process.env.PSP_DOCKER;
|
|
|
|
|
|
2020-06-16 17:49:30 -04:00
|
|
|
let IMAGE = "manylinux2010";
|
2020-06-22 10:15:40 -04:00
|
|
|
|
|
|
|
|
if (IS_DOCKER) {
|
|
|
|
|
// defaults to 2010
|
2021-09-12 14:08:32 -04:00
|
|
|
let MANYLINUX_VERSION = getarg("--manylinux2010")
|
|
|
|
|
? "manylinux2010"
|
|
|
|
|
: getarg("--manylinux2014")
|
|
|
|
|
? "manylinux2014"
|
|
|
|
|
: "";
|
2020-06-22 10:15:40 -04:00
|
|
|
IMAGE = python_image(MANYLINUX_VERSION, PYTHON);
|
|
|
|
|
}
|
2019-01-06 09:45:06 -05:00
|
|
|
|
2020-06-16 17:49:30 -04:00
|
|
|
let python_path;
|
|
|
|
|
|
|
|
|
|
if (IS_DOCKER) {
|
|
|
|
|
python_path = "python/perspective";
|
|
|
|
|
} else {
|
|
|
|
|
// When running locally, tests need to run in UTC and not the machine's
|
|
|
|
|
// local timezone.
|
|
|
|
|
process.env.TZ = "UTC";
|
|
|
|
|
python_path = resolve`${__dirname}/../python/perspective`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Run `pytest` for client mode PerspectiveWidget, which need to be on a
|
|
|
|
|
* separate runtime from the other Python tests.
|
|
|
|
|
*/
|
2021-09-12 14:08:32 -04:00
|
|
|
const pytest_client_mode = (IS_DOCKER) => {
|
2020-06-22 10:15:40 -04:00
|
|
|
if (IS_DOCKER) {
|
2020-06-16 17:49:30 -04:00
|
|
|
return bash`${docker(IMAGE)} bash -c "cd \
|
2022-01-17 23:56:25 -05:00
|
|
|
python/perspective && TZ=UTC PYTHONMALLOC=debug ${PYTHON} -m pytest \
|
2021-05-17 21:18:07 +08:00
|
|
|
${VERBOSE ? "-vv --full-trace" : ""} --noconftest
|
2020-09-17 23:16:08 -04:00
|
|
|
perspective/tests/client_mode"`;
|
2019-01-06 09:55:57 -05:00
|
|
|
} else {
|
2022-01-17 23:56:25 -05:00
|
|
|
return bash`cd ${python_path} && PYTHONMALLOC=debug ${PYTHON} -m pytest \
|
2022-02-25 03:28:48 -05:00
|
|
|
${VERBOSE ? "-vv --full-trace" : ""} --noconftest
|
|
|
|
|
--disable-pytest-warnings
|
2020-09-17 23:16:08 -04:00
|
|
|
perspective/tests/client_mode`;
|
2020-06-16 17:49:30 -04:00
|
|
|
}
|
|
|
|
|
};
|
2020-01-06 15:00:28 -05:00
|
|
|
|
2020-06-16 17:49:30 -04:00
|
|
|
/**
|
|
|
|
|
* Run `pytest` for the `perspective-python` library.
|
|
|
|
|
*/
|
2021-09-12 14:08:32 -04:00
|
|
|
const pytest = (IS_DOCKER) => {
|
2020-06-16 17:49:30 -04:00
|
|
|
if (IS_DOCKER) {
|
|
|
|
|
return bash`${docker(IMAGE)} bash -c "cd \
|
2022-01-17 23:56:25 -05:00
|
|
|
python/perspective && TZ=UTC PYTHONMALLOC=debug ${PYTHON} -m pytest \
|
2021-05-17 21:18:07 +08:00
|
|
|
${VERBOSE ? "-vv --full-trace" : ""} perspective \
|
2020-09-18 19:07:42 -04:00
|
|
|
--ignore=perspective/tests/client_mode \
|
2022-02-25 03:28:48 -05:00
|
|
|
--disable-pytest-warnings
|
2020-06-16 17:49:30 -04:00
|
|
|
--cov=perspective"`;
|
|
|
|
|
} else {
|
2022-01-17 23:56:25 -05:00
|
|
|
return bash`cd ${python_path} && PYTHONMALLOC=debug ${PYTHON} -m pytest \
|
2021-05-17 21:18:07 +08:00
|
|
|
${VERBOSE ? "-vv --full-trace" : ""} perspective \
|
2020-09-18 19:07:42 -04:00
|
|
|
--ignore=perspective/tests/client_mode \
|
2022-02-25 03:28:48 -05:00
|
|
|
--disable-pytest-warnings
|
2020-06-16 17:49:30 -04:00
|
|
|
${COVERAGE ? "--cov=perspective" : ""}`;
|
2019-01-06 09:55:57 -05:00
|
|
|
}
|
2020-06-16 17:49:30 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Check that the `PYTHON` command is valid, else default to `python`.
|
|
|
|
|
try {
|
2020-06-16 18:51:18 -04:00
|
|
|
execute_throw`${PYTHON} --version`;
|
2020-06-16 17:49:30 -04:00
|
|
|
} catch (e) {
|
2020-06-16 18:51:18 -04:00
|
|
|
console.warn(`\`${PYTHON}\` not found - using \`python\` instead.`);
|
2020-06-16 17:49:30 -04:00
|
|
|
PYTHON = "python";
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-31 13:25:40 -04:00
|
|
|
// Check that the `PYTHON` command is valid, else default to `python`.
|
|
|
|
|
try {
|
|
|
|
|
execute_throw`${PYTHON} --version`;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.warn(`\`${PYTHON}\` not found - using \`python\` instead.`);
|
|
|
|
|
PYTHON = "python";
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-16 17:49:30 -04:00
|
|
|
try {
|
|
|
|
|
execute(pytest_client_mode(IS_DOCKER));
|
|
|
|
|
execute(pytest(IS_DOCKER));
|
2019-01-06 09:55:57 -05:00
|
|
|
} catch (e) {
|
2019-01-17 20:51:06 -05:00
|
|
|
console.log(e.message);
|
2019-01-06 09:55:57 -05:00
|
|
|
process.exit(1);
|
|
|
|
|
}
|