Skip to content

chore: Remove create:testdata/clean:testdata in package.json #148

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

Merged
merged 1 commit into from
Jun 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
105 changes: 0 additions & 105 deletions gulp/test-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,108 +81,3 @@ export const testTask = ((cache, execArgv, testOptions) => memoizeTask(cache, fu
};
return asyncDone(() => child_process.spawn(`node`, args, opts));
}))({}, [jest, ...jestArgv], testOptions);

// Pull C++ and Java paths from environment vars first, otherwise sane defaults
const ARROW_HOME = process.env.ARROW_HOME || path.resolve('../');
const ARROW_JAVA_DIR = process.env.ARROW_JAVA_DIR || path.join(ARROW_HOME, 'java');
const CPP_EXE_PATH = process.env.ARROW_CPP_EXE_PATH || path.join(ARROW_HOME, 'cpp/build/debug');
const ARROW_ARCHERY_DIR = process.env.ARROW_ARCHERY_DIR || path.join(ARROW_HOME, 'dev/archery');
const CPP_JSON_TO_ARROW = path.join(CPP_EXE_PATH, 'arrow-json-integration-test');
const CPP_FILE_TO_STREAM = path.join(CPP_EXE_PATH, 'arrow-file-to-stream');

const testFilesDir = path.join(ARROW_HOME, 'js/test/data');
const snapshotsDir = path.join(ARROW_HOME, 'js/test/__snapshots__');
const cppFilesDir = path.join(testFilesDir, 'cpp');
const javaFilesDir = path.join(testFilesDir, 'java');
const jsonFilesDir = path.join(testFilesDir, 'json');

export async function cleanTestData() {
return await del([
`${cppFilesDir}/**`,
`${javaFilesDir}/**`,
`${jsonFilesDir}/**`,
`${snapshotsDir}/**`
]);
}

async function createTestJSON() {
await mkdirp(jsonFilesDir);
await exec(`python3 -B -c '\
import sys\n\
sys.path.append("${ARROW_ARCHERY_DIR}")\n\
from archery.integration.runner import write_js_test_json\n\
write_js_test_json("${jsonFilesDir}")'`);
}

export async function createTestData() {

let JAVA_TOOLS_JAR = process.env.ARROW_JAVA_INTEGRATION_JAR;
if (!JAVA_TOOLS_JAR) {
const pom_version = await
readFile(path.join(ARROW_JAVA_DIR, 'pom.xml'))
.then((pom) => parseXML(pom.toString()))
.then((pomXML) => pomXML.project.version[0]);
JAVA_TOOLS_JAR = path.join(ARROW_JAVA_DIR, `/tools/target/arrow-tools-${pom_version}-jar-with-dependencies.jar`);
}

await cleanTestData().then(createTestJSON);
await mkdirp(path.join(cppFilesDir, 'file'));
await mkdirp(path.join(javaFilesDir, 'file'));
await mkdirp(path.join(cppFilesDir, 'stream'));
await mkdirp(path.join(javaFilesDir, 'stream'));

const errors = [];
const names = await glob(path.join(jsonFilesDir, '*.json'));

for (const jsonPath of names) {
const name = path.parse(path.basename(jsonPath)).name;
const arrowCppFilePath = path.join(cppFilesDir, 'file', `${name}.arrow`);
const arrowJavaFilePath = path.join(javaFilesDir, 'file', `${name}.arrow`);
const arrowCppStreamPath = path.join(cppFilesDir, 'stream', `${name}.arrow`);
const arrowJavaStreamPath = path.join(javaFilesDir, 'stream', `${name}.arrow`);
try {
await generateCPPFile(path.resolve(jsonPath), arrowCppFilePath);
await generateCPPStream(arrowCppFilePath, arrowCppStreamPath);
} catch (e) { errors.push(`${e.stdout}\n${e.message}`); }
try {
await generateJavaFile(path.resolve(jsonPath), arrowJavaFilePath);
await generateJavaStream(arrowJavaFilePath, arrowJavaStreamPath);
} catch (e) { errors.push(`${e.stdout}\n${e.message}`); }
}
if (errors.length) {
console.error(errors.join(`\n`));
process.exit(1);
}

async function generateCPPFile(jsonPath, filePath) {
await del(filePath);
return await exec(
`${CPP_JSON_TO_ARROW} ${`--integration --mode=JSON_TO_ARROW`} ${`--json=${jsonPath} --arrow=${filePath}`}`,
{ maxBuffer: Math.pow(2, 53) - 1 }
);
}

async function generateCPPStream(filePath, streamPath) {
await del(streamPath);
return await exec(
`${CPP_FILE_TO_STREAM} ${filePath} > ${streamPath}`,
{ maxBuffer: Math.pow(2, 53) - 1 }
);
}

async function generateJavaFile(jsonPath, filePath) {
await del(filePath);
return await exec(
`java -cp ${JAVA_TOOLS_JAR} ${`org.apache.arrow.tools.Integration -c JSON_TO_ARROW`} ${`-j ${path.resolve(jsonPath)} -a ${filePath}`}`,
{ maxBuffer: Math.pow(2, 53) - 1 }
);
}

async function generateJavaStream(filePath, streamPath) {
await del(streamPath);
return await exec(
`java -cp ${JAVA_TOOLS_JAR} ${`org.apache.arrow.tools.FileToStream`} ${filePath} ${streamPath}`,
{ maxBuffer: Math.pow(2, 53) - 1 }
);
}
}
4 changes: 1 addition & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { mergeMap } from "rxjs/operators";
import cleanTask from "./gulp/clean-task.js";
import compileTask from "./gulp/compile-task.js";
import packageTask from "./gulp/package-task.js";
import { testTask, createTestData, cleanTestData } from "./gulp/test-task.js";
import { testTask } from "./gulp/test-task.js";
import { esbuildTask, rollupTask, webpackTask, execBundleTask } from "./gulp/bundle-task.js";
import { taskName, combinations, targetDir, knownTargets, npmPkgName, tasksToSkipPerTargetOrFormat, targetAndModuleCombinations } from "./gulp/util.js";

Expand Down Expand Up @@ -76,8 +76,6 @@ gulp.task(`build:${npmPkgName}`,
);

// And finally the global composite tasks
gulp.task(`clean:testdata`, cleanTestData);
gulp.task(`create:testdata`, createTestData);
gulp.task(`test`, gulpConcurrent(getTasks(`test`)));
gulp.task(`clean`, gulp.parallel(getTasks(`clean`)));
gulp.task(`build`, gulpConcurrent(getTasks(`build`)));
Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
"perf": "node --no-warnings --loader ts-node/esm/transpile-only perf/index.ts",
"test:integration": "bin/integration.ts --mode validate",
"release": "./npm-release.sh",
"clean:all": "yarn clean && yarn clean:testdata",
"clean:testdata": "gulp clean:testdata",
"create:testdata": "gulp create:testdata",
"test:coverage": "gulp test -t src --coverage",
"test:bundle": "gulp bundle",
"doc": "del-cli ./doc && typedoc",
Expand Down