Propagate the results of running the run.sh script.
parent
400388b262
commit
537226c651
|
@ -3,7 +3,6 @@
|
||||||
TODO:
|
TODO:
|
||||||
- [ ] Make free-ing data consistent with null pointers.
|
- [ ] Make free-ing data consistent with null pointers.
|
||||||
- [ ] Add documentation throughout (ownership, docstrings, etc.).
|
- [ ] Add documentation throughout (ownership, docstrings, etc.).
|
||||||
- [ ] Have main.c return status code of run.sh.
|
|
||||||
- [ ] Organize variables in each function to the top?
|
- [ ] Organize variables in each function to the top?
|
||||||
|
|
||||||
CLI utility for initializing projects in reproducible ways.
|
CLI utility for initializing projects in reproducible ways.
|
||||||
|
|
|
@ -22,6 +22,7 @@ enum ErrorCode {
|
||||||
ERROR_VALIDATOR_FIELD_PROMPT_INVALID,
|
ERROR_VALIDATOR_FIELD_PROMPT_INVALID,
|
||||||
|
|
||||||
ERROR_EVALUATOR_RUN_SH_NOT_FOUND,
|
ERROR_EVALUATOR_RUN_SH_NOT_FOUND,
|
||||||
|
ERROR_EVALUATOR_RUN_SH_NOT_EXEC,
|
||||||
ERROR_EVALUATOR_RESPONSE_INVALID,
|
ERROR_EVALUATOR_RESPONSE_INVALID,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,10 @@
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "validator.h"
|
#include "validator.h"
|
||||||
|
|
||||||
struct Error *evaluate_spec_json(
|
int evaluate_run_sh(
|
||||||
const struct Config *const config, const struct DynArray *const prompts
|
const struct Config *const config,
|
||||||
|
const struct DynArray *const prompts,
|
||||||
|
struct Error **error
|
||||||
);
|
);
|
||||||
|
|
||||||
#endif /* _BOOTSTRAP_EVALUATOR_H */
|
#endif /* _BOOTSTRAP_EVALUATOR_H */
|
||||||
|
|
7
main.c
7
main.c
|
@ -38,13 +38,13 @@ static int run(const char *root_dir, const char *target) {
|
||||||
goto cleanup_parsed;
|
goto cleanup_parsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((error = evaluate_spec_json(config, prompts))) {
|
if ((retval = evaluate_run_sh(config, prompts, &error))) {
|
||||||
|
if (error) {
|
||||||
fprintf(stderr, "%s", error->message);
|
fprintf(stderr, "%s", error->message);
|
||||||
|
}
|
||||||
goto cleanup_parsed;
|
goto cleanup_parsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = EXIT_SUCCESS;
|
|
||||||
|
|
||||||
cleanup_prompts:
|
cleanup_prompts:
|
||||||
if (prompts) {
|
if (prompts) {
|
||||||
dyn_array_free(prompts);
|
dyn_array_free(prompts);
|
||||||
|
@ -61,6 +61,7 @@ cleanup_config:
|
||||||
cleanup_cwd:
|
cleanup_cwd:
|
||||||
free(cwd);
|
free(cwd);
|
||||||
error_free(error);
|
error_free(error);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,17 +24,25 @@ static struct Error *find_run_sh(const struct Config *const config) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Check run.sh is executable.
|
if (!(sb.st_mode & S_IXUSR)) {
|
||||||
|
return ERROR_NEW(
|
||||||
|
ERROR_EVALUATOR_RUN_SH_NOT_EXEC,
|
||||||
|
config->target,
|
||||||
|
"/run.sh is not executable."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Error *evaluate_spec_json(
|
int evaluate_run_sh(
|
||||||
const struct Config *const config, const struct DynArray *const prompts
|
const struct Config *const config,
|
||||||
|
const struct DynArray *const prompts,
|
||||||
|
struct Error **error
|
||||||
) {
|
) {
|
||||||
struct Error *error = find_run_sh(config);
|
*error = find_run_sh(config);
|
||||||
if (error) {
|
if (*error) {
|
||||||
return error;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prompts) {
|
if (prompts) {
|
||||||
|
@ -61,8 +69,7 @@ struct Error *evaluate_spec_json(
|
||||||
|
|
||||||
free(filepath);
|
free(filepath);
|
||||||
|
|
||||||
// TODO: Want to return this status out.
|
int exit_code = system(command);
|
||||||
int status = system(command);
|
free((void *)command);
|
||||||
|
return WEXITSTATUS(exit_code);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue