Skip to content

Commit

Permalink
Migrate -Ilib -> -I. (except for Cro, which we save for later)
Browse files Browse the repository at this point in the history
  • Loading branch information
ab5tract committed Sep 20, 2024
1 parent 58cbed2 commit f94be57
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected void configureCro(Project project) {
}
}
setEnvs(environment);
setInterpreterParameters("-Ilib");
setInterpreterParameters("-I.");
}
catch (Exception ignore) {
// Was not able to load a configuration from .cro.yml,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/raku/comma/grammar/CurrentGrammar.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private void startUpdate() {
// Run and get output.
RakuCommandLine cmd = new RakuCommandLine(project);
cmd.setWorkDirectory(project.getBasePath());
cmd.addParameter("-Ilib");
cmd.addParameter("-I.");
cmd.addParameter(tweakedGrammarAsFile.getAbsolutePath());
cancelled = false;
List<String> lines = executeAndRead(cmd, tweakedGrammarAsFile);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/raku/comma/repl/RakuReplConsole.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected Process createProcess() throws ExecutionException {
myReplBackendFile = RakuUtils.getResourceAsFile("repl/repl-backend.p6");
commandLine = new RakuCommandLine(getProject());
commandLine.setWorkDirectory(getProject().getBasePath());
commandLine.addParameter("-Ilib");
commandLine.addParameter("-I.");
commandLine.addParameter(myReplBackendFile.getAbsolutePath());
return commandLine.createProcess();
}
Expand Down
21 changes: 12 additions & 9 deletions src/main/java/org/raku/comma/run/RakuRunConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ abstract public class RakuRunConfiguration extends LocatableConfigurationBase im
private String workingDirectory;
private Map<String, String> envVars = new HashMap<>();
private boolean passParentEnvs;
private String interpreterParameters;
private String interpreterParameters = "-I.";
private boolean myStartSuspended;
private int myDebugPort;
// default value on creation, later overwritten if we initialize from a saved configuration
Expand Down Expand Up @@ -80,13 +80,17 @@ public void readExternal(@NotNull Element element) throws InvalidDataException {
Element debugPortElem = element.getChild(DEBUG_PORT);
Element startSuspendedElem = element.getChild(START_SUSPENDED);
Element logTimelineEvents = element.getChild(LOG_TIMELINE_EVENTS);
if (scriptPathElem == null || scriptArgsElem == null ||
workDirectoryElem == null || envVarsElem == null ||
passEnvElem == null || rakuParamsElem == null ||
debugPortElem == null || startSuspendedElem == null) {
if (scriptPathElem == null
|| scriptArgsElem == null
|| workDirectoryElem == null
|| envVarsElem == null
|| passEnvElem == null
|| rakuParamsElem == null
|| debugPortElem == null
|| startSuspendedElem == null)
{
throw new InvalidDataException();
}
else {
} else {
scriptPath = scriptPathElem.getText();
scriptArgs = scriptArgsElem.getText();
workingDirectory = workDirectoryElem.getText();
Expand All @@ -99,8 +103,7 @@ public void readExternal(@NotNull Element element) throws InvalidDataException {
myStartSuspended = Boolean.parseBoolean(startSuspendedElem.getText());
if (logTimelineEvents == null) {
myLogTimelineEvents = Strings.join(Arrays.asList("await", "file", "process", "socket", "start"), ";");
}
else {
} else {
myLogTimelineEvents = logTimelineEvents.getText();
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/raku/comma/run/RakuRunSettingsEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ protected void resetEditorFrom(@NotNull RakuRunConfiguration conf) {
String events = conf.getLogTimelineEvents();
List<Integer> indexes = new ArrayList<>();
for (int i = 0; i < LOG_TIMELINE_EVENT_TYPES.length; i++) {
if (events.contains(LOG_TIMELINE_EVENT_TYPES[i]))
if (events.contains(LOG_TIMELINE_EVENT_TYPES[i])) {
indexes.add(i);
}
}
myLogTimelineOptions.setSelectedIndices(indexes.stream().mapToInt(i -> i).toArray());
}
Expand Down Expand Up @@ -138,7 +139,7 @@ public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
private LabeledComponent<?> myFileComponent;
private LabeledComponent<RawCommandLineEditor> myRakuParametersComponent;
private final Predicate<Component> panelPredicate = component -> component instanceof JComponent
&& component instanceof PanelWithAnchor;
&& component instanceof PanelWithAnchor;

@Override
protected void addComponents() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/raku/comma/sdk/RakuSdkType.java
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ public static List<RakuSymbol> loadModuleSymbols(Project project,
RakuCommandLine cmd = new RakuCommandLine(project);
cmd.setWorkDirectory(project.getBasePath());
if (addLib) {
cmd.addParameter("-Ilib");
cmd.addParameter("-I.");
}
cmd.addParameters(moduleSymbols.getPath(), invocation);
String text = String.join("\n", cmd.executeAndRead(moduleSymbols));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,24 @@ protected boolean setupConfigurationFromContext(@NotNull RakuTestRunConfiguratio
private static String calculateParameters(ContentEntry contentEntryToTest) {
VirtualFile rakuModuleRoot = contentEntryToTest.getFile();
if (rakuModuleRoot == null) return "";
StringJoiner argsLine = new StringJoiner(" ");
Arrays.stream(contentEntryToTest.getSourceFolders()).forEachOrdered((sourceFolder) -> {
if (sourceFolder.isTestSource()) return;
VirtualFile dir = sourceFolder.getFile();
if (dir == null) return;
String rootPath = rakuModuleRoot.getPath();
if (!rootPath.isEmpty()) {
argsLine.add("-I" + dir.getPath().substring(rootPath.length() + 1));
}
});
return argsLine.toString();
// The recommendation is to always run with -I. and an up-to-date META6.json
// THe below code instead tries to include every (non-test-source) content entry,
// which sounds vaguely useful but also:
// a) uncommon (almost all Raku code appears to use lib/ exclusively as a single source root)
// b) should be fixable (or is already irrelevant) when using -I.
// But I've left it here just in case it turns out to be a useful artifact in the future.
// StringJoiner argsLine = new StringJoiner(" ");
// Arrays.stream(contentEntryToTest.getSourceFolders()).forEachOrdered((sourceFolder) -> {
// if (sourceFolder.isTestSource()) return;
// VirtualFile dir = sourceFolder.getFile();
// if (dir == null) return;
// String rootPath = rakuModuleRoot.getPath();
// if (!rootPath.isEmpty()) {
// argsLine.add("-I" + dir.getPath().substring(rootPath.length() + 1));
// }
// });

return "-I.";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ abstract public class RakuTestRunConfiguration extends RunConfigurationBase<RunP
private static final String PASS_PARENT_ENV = "PASS_PARENT_ENV";
private boolean passParentEnvs = true;
private static final String INTERPRETER_PARAMETERS = "INTERPRETER_PARAMETERS";
private String interpreterArguments = "-Ilib";
private String interpreterArguments = "-I.";

public RakuTestRunConfiguration(@NotNull Project project, @NotNull ConfigurationFactory factory) {
super(project, factory, "Raku test");
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/raku/comma/testing/RakuTestSettingsEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
public class RakuTestSettingsEditor extends SettingsEditor<RakuTestRunConfiguration> {
protected Project myProject;
protected JTextField myDegreeField;
protected RawCommandLineEditor myPerl6ParametersPanel;
protected RawCommandLineEditor myRakuParametersPanel;
protected EnvironmentVariablesComponent myEnvVariablesField;
// Specific controls
protected JComboBox<RakuTestKind> myKindField;
Expand Down Expand Up @@ -64,7 +64,7 @@ protected void resetEditorFrom(@NotNull RakuTestRunConfiguration configuration)
myDegreeField.setText(String.valueOf(configuration.getParallelismDegree()));
myEnvVariablesField.setEnvs(configuration.getEnvs());
myEnvVariablesField.setPassParentEnvs(configuration.isPassParentEnvs());
myPerl6ParametersPanel.setText(configuration.getInterpreterArguments());
myRakuParametersPanel.setText(configuration.getInterpreterArguments());
}

@Override
Expand Down Expand Up @@ -113,7 +113,7 @@ protected void applyEditorTo(@NotNull RakuTestRunConfiguration configuration) th
}
configuration.setEnvs(myEnvVariablesField.getEnvs());
configuration.setPassParentEnvs(myEnvVariablesField.isPassParentEnvs());
configuration.setInterpreterArguments(myPerl6ParametersPanel.getText());
configuration.setInterpreterArguments(myRakuParametersPanel.getText());
configuration.setTestPattern(myFilePatternField.getText());
}

Expand Down Expand Up @@ -174,7 +174,7 @@ public void insertString(int offs, String str, AttributeSet a) throws BadLocatio
};
}
};
myPerl6ParametersPanel = new RawCommandLineEditor();
myRakuParametersPanel = new RawCommandLineEditor();
myEnvVariablesField = new EnvironmentVariablesComponent();

setupSpecificComponents(panel);
Expand All @@ -183,7 +183,7 @@ public void insertString(int offs, String str, AttributeSet a) throws BadLocatio
panel.add(new JLabel("Tests run in parallel"), "align label");
panel.add(myDegreeField, "wrap, growx");
panel.add(new JLabel("Raku parameters"), "align label");
panel.add(myPerl6ParametersPanel, "wrap, growx");
panel.add(myRakuParametersPanel, "wrap, growx");
panel.add(new JLabel("Environment variables:"), "align label");
panel.add(myEnvVariablesField.getComponent(), "growx");

Expand Down

0 comments on commit f94be57

Please sign in to comment.