From d50ba0b325f29855b3c1b04a841aa917113ad15b Mon Sep 17 00:00:00 2001 From: Charuka Tharindu Date: Thu, 25 May 2023 14:52:47 +0530 Subject: [PATCH 1/2] Update logs and help text --- .../org/ballerinalang/command/cmd/UpdateCommand.java | 10 ++++------ src/main/resources/cli-help/ballerina-dist-pull.help | 12 +++++------- .../resources/cli-help/ballerina-dist-remove.help | 4 ++-- .../resources/cli-help/ballerina-dist-update.help | 6 ++---- src/main/resources/cli-help/ballerina-dist-use.help | 4 ++-- 5 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/ballerinalang/command/cmd/UpdateCommand.java b/src/main/java/org/ballerinalang/command/cmd/UpdateCommand.java index 6b6b49a5..5d525ef9 100644 --- a/src/main/java/org/ballerinalang/command/cmd/UpdateCommand.java +++ b/src/main/java/org/ballerinalang/command/cmd/UpdateCommand.java @@ -89,21 +89,19 @@ public static void update(PrintStream printStream) { } String version = ToolUtil.getCurrentBallerinaVersion(); String distVersion = ToolUtil.getType(version) + "-" + version; - printStream.println("Fetching the latest patch distribution for '" + distVersion + "' from " + - "the remote server..."); + printStream.println("Fetching the latest distribution from the remote server..."); String latestVersion = ToolUtil.getLatest(version, "patch"); if (latestVersion == null) { - printStream.println("Failed to find the latest patch distribution for '" + distVersion + "'"); + printStream.println("Failed to find the latest Ballerina distribution"); return; } if (!latestVersion.equals(version)) { ToolUtil.downloadDistribution(printStream, latestVersion, ToolUtil.getType(latestVersion), latestVersion, testFlag); ToolUtil.useBallerinaVersion(printStream, latestVersion); - printStream.println("Successfully set the latest patch distribution '" + latestVersion + "' as the " + - "active distribution"); + printStream.println("Successfully set the distribution '" + latestVersion + "' as the active distribution"); return; } - printStream.println("The latest patch distribution '" + latestVersion + "' is already the active distribution"); + printStream.println("The latest distribution '" + latestVersion + "' is already the active distribution"); } } diff --git a/src/main/resources/cli-help/ballerina-dist-pull.help b/src/main/resources/cli-help/ballerina-dist-pull.help index d1931809..2cd0a9d7 100644 --- a/src/main/resources/cli-help/ballerina-dist-pull.help +++ b/src/main/resources/cli-help/ballerina-dist-pull.help @@ -7,15 +7,13 @@ SYNOPSIS DESCRIPTION Fetch the specified distribution with its dependencies to your local environment, and mark it as the active version. - - The `bal dist pull latest` command fetches the latest ballerina version. - The `bal dist update` update command always fetches the latest patch version whereas + The `bal dist update` update command always fetches the latest distribution version whereas this command allows you to fetch and use any distribution. EXAMPLES - Fetch Ballerina `1.2.19` version and mark it as the active distribution. - $ bal dist pull 1.2.19 + Fetch Ballerina `2201.4.2` version and mark it as the active distribution. + $ bal dist pull 2201.4.2 - Fetch Ballerina `slbeta3` version and mark it as the active distribution. - $ bal dist pull slbeta3 + Fetch Ballerina `2201.5.0` version and mark it as the active distribution. + $ bal dist pull 2201.5.0 diff --git a/src/main/resources/cli-help/ballerina-dist-remove.help b/src/main/resources/cli-help/ballerina-dist-remove.help index b23e44d9..63d91ef0 100644 --- a/src/main/resources/cli-help/ballerina-dist-remove.help +++ b/src/main/resources/cli-help/ballerina-dist-remove.help @@ -16,8 +16,8 @@ DESCRIPTION However, you are not allowed to remove the currently active distribution. EXAMPLES - Remove the 1.2.19 version from your local machine. - $ bal dist remove 1.2.19 + Remove the 2201.5.0 version from your local machine. + $ bal dist remove 2201.5.0 Remove all the Ballerina distributions except the currently active one from your local machine. diff --git a/src/main/resources/cli-help/ballerina-dist-update.help b/src/main/resources/cli-help/ballerina-dist-update.help index 848d32bf..77e48f92 100644 --- a/src/main/resources/cli-help/ballerina-dist-update.help +++ b/src/main/resources/cli-help/ballerina-dist-update.help @@ -1,14 +1,12 @@ NAME - bal-dist-update - Update to the latest patch version of the active distribution + bal-dist-update - Update to the latest Ballerina version SYNOPSIS bal dist update DESCRIPTION - Fetch the latest patch version of your active distribution with its dependencies - (when your active distribution is another version), + Fetch the latest version with its dependencies (when your active distribution is another version), and mark it as the active version. - However, this will not fetch the latest minor version if any. diff --git a/src/main/resources/cli-help/ballerina-dist-use.help b/src/main/resources/cli-help/ballerina-dist-use.help index a1586def..bcbaa5af 100644 --- a/src/main/resources/cli-help/ballerina-dist-use.help +++ b/src/main/resources/cli-help/ballerina-dist-use.help @@ -8,5 +8,5 @@ DESCRIPTION Mark the specified Ballerina distribution as the active distribution. EXAMPLES - Mark 1.2.19 as the active distribution. - $ bal dist use 1.2.19 + Mark 2201.5.0 as the active distribution. + $ bal dist use 2201.5.0 From 79e50c009d08478452fdae3eaf09da9e4de5aa5f Mon Sep 17 00:00:00 2001 From: Charuka Tharindu Date: Thu, 25 May 2023 15:28:04 +0530 Subject: [PATCH 2/2] Update the test cases --- gradle.properties | 2 +- .../command/PullCommandTest.java | 6 ++-- .../command/RemoveCommandTest.java | 11 +++--- .../command/UpdateCommandTest.java | 8 ++--- .../ballerinalang/command/UseCommandTest.java | 6 ++-- .../distribution/UpdateToolTest.java | 36 +++++++++---------- 6 files changed, 33 insertions(+), 36 deletions(-) diff --git a/gradle.properties b/gradle.properties index 2c754625..59fc382b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,4 +10,4 @@ swan-lake-latest-version=2201.5.0 swan-lake-latest-spec-version=2022R4 1-x-channel-version=1.2.0 1-x-channel-spec-version=2020R1 -1-x-channel-latest-version=1.2.16 +1-x-channel-latest-version=1.2.38 diff --git a/src/test/java/org/ballerinalang/command/PullCommandTest.java b/src/test/java/org/ballerinalang/command/PullCommandTest.java index 7a1b686b..566b4490 100644 --- a/src/test/java/org/ballerinalang/command/PullCommandTest.java +++ b/src/test/java/org/ballerinalang/command/PullCommandTest.java @@ -74,11 +74,11 @@ public void pullCommandHelpTest() { @Test public void pullDistributionTest() { PullCommand pullCommand = new PullCommand(testStream); - new CommandLine(pullCommand).parse("slp1"); + new CommandLine(pullCommand).parse("2201.4.0"); pullCommand.execute(); Assert.assertTrue(outContent.toString().contains("Checking for newer versions of the update tool")); - Assert.assertTrue(outContent.toString().contains("Fetching the 'slp1' distribution from the remote server")); - Assert.assertTrue(outContent.toString().contains("Fetching the dependencies for 'slp1' from the remote server")); + Assert.assertTrue(outContent.toString().contains("Fetching the '2201.4.0' distribution from the remote server")); + Assert.assertTrue(outContent.toString().contains("Fetching the dependencies for '2201.4.0' from the remote server")); Assert.assertTrue(outContent.toString().contains("successfully set as the active distribution")); } diff --git a/src/test/java/org/ballerinalang/command/RemoveCommandTest.java b/src/test/java/org/ballerinalang/command/RemoveCommandTest.java index ecee20d6..10480487 100644 --- a/src/test/java/org/ballerinalang/command/RemoveCommandTest.java +++ b/src/test/java/org/ballerinalang/command/RemoveCommandTest.java @@ -82,28 +82,27 @@ public void removeActiveDistTest() { @Test public void removeCommandTest() { PullCommand pullCommand = new PullCommand(testStream); - new CommandLine(pullCommand).parse("1.2.0"); + new CommandLine(pullCommand).parse("2201.5.0"); pullCommand.execute(); UpdateCommand updateCommand = new UpdateCommand(testStream); new CommandLine(updateCommand).parse(); updateCommand.execute(); PullCommand pullCmd = new PullCommand(testStream); - new CommandLine(pullCmd).parse("slp1"); + new CommandLine(pullCmd).parse("2201.4.2"); pullCmd.execute(); - updateCommand.execute(); RemoveCommand removeCommand2 = new RemoveCommand(testStream); - new CommandLine(removeCommand2).parse("1.2.0"); + new CommandLine(removeCommand2).parse("2201.5.0"); removeCommand2.execute(); Assert.assertTrue(outContent.toString().contains("successfully removed")); try { RemoveCommand removeCommand = new RemoveCommand(testStream); - new CommandLine(removeCommand).parse("slp2"); + new CommandLine(removeCommand).parse("2201.3.5"); removeCommand.execute(); } catch (CommandException e) { - Assert.assertTrue(e.getMessages().get(0).contains("distribution 'slp2' not found")); + Assert.assertTrue(e.getMessages().get(0).contains("distribution '2201.3.5' not found")); } RemoveCommand removeCommand3 = new RemoveCommand(testStream); diff --git a/src/test/java/org/ballerinalang/command/UpdateCommandTest.java b/src/test/java/org/ballerinalang/command/UpdateCommandTest.java index 8c3f1585..37685143 100644 --- a/src/test/java/org/ballerinalang/command/UpdateCommandTest.java +++ b/src/test/java/org/ballerinalang/command/UpdateCommandTest.java @@ -36,7 +36,7 @@ public void updateCommandHelpTest() { UpdateCommand updateCommand = new UpdateCommand(testStream); new CommandLine(updateCommand).parse("-h"); updateCommand.execute(); - Assert.assertTrue(outContent.toString().contains("Update to the latest patch version of the active distribution")); + Assert.assertTrue(outContent.toString().contains("Update to the latest Ballerina version")); } @Test @@ -53,13 +53,13 @@ public void UpdateCommandWithArgTest() { @Test public void updateCommandTest() { PullCommand pullCommand = new PullCommand(testStream); - new CommandLine(pullCommand).parse("slp1"); + new CommandLine(pullCommand).parse("2201.4.1"); pullCommand.execute(); UpdateCommand updateCommand = new UpdateCommand(testStream); new CommandLine(updateCommand).parse(); updateCommand.execute(); - Assert.assertTrue(outContent.toString().contains("Fetching the latest patch distribution")); - Assert.assertTrue(outContent.toString().contains("Successfully set the latest patch distribution")); + Assert.assertTrue(outContent.toString().contains("Fetching the latest distribution")); + Assert.assertTrue(outContent.toString().contains("Successfully set the distribution")); UpdateCommand updateCmd = new UpdateCommand(testStream); new CommandLine(updateCmd).parse(); diff --git a/src/test/java/org/ballerinalang/command/UseCommandTest.java b/src/test/java/org/ballerinalang/command/UseCommandTest.java index c9e94b38..d0fa8fd6 100644 --- a/src/test/java/org/ballerinalang/command/UseCommandTest.java +++ b/src/test/java/org/ballerinalang/command/UseCommandTest.java @@ -36,14 +36,14 @@ public class UseCommandTest extends CommandTest { @Test public void useCommandTest() { PullCommand pullCommand = new PullCommand(testStream); - new CommandLine(pullCommand).parse("slbeta6"); + new CommandLine(pullCommand).parse("2201.5.0"); pullCommand.execute(); UpdateCommand updateCommand = new UpdateCommand(testStream); new CommandLine(updateCommand).parse(); updateCommand.execute(); UseCommand useCommand = new UseCommand(testStream); - new CommandLine(useCommand).parse("slbeta6"); + new CommandLine(useCommand).parse("2201.5.0"); useCommand.execute(); Assert.assertTrue(outContent.toString().contains("successfully set as the active distribution")); @@ -51,7 +51,7 @@ public void useCommandTest() { Assert.assertTrue(outContent.toString().contains("is the current active distribution version")); UseCommand useCmd = new UseCommand(testStream); - new CommandLine(useCmd).parse("slp3"); + new CommandLine(useCmd).parse("2201.4.0"); useCmd.execute(); Assert.assertTrue(outContent.toString().contains("not found")); diff --git a/src/test/java/org/ballerinalang/distribution/UpdateToolTest.java b/src/test/java/org/ballerinalang/distribution/UpdateToolTest.java index cc439085..fe839abe 100644 --- a/src/test/java/org/ballerinalang/distribution/UpdateToolTest.java +++ b/src/test/java/org/ballerinalang/distribution/UpdateToolTest.java @@ -153,10 +153,9 @@ public void testUpdateCommand() throws IOException, InterruptedException { args.add("update"); args.add("--test"); output = TestUtils.executeCommand(args); - Assert.assertTrue(output.contains("Fetching the latest patch distribution for 'ballerina-" + swanLakeVersion + - "' from the remote server...")); - Assert.assertTrue(output.contains("Successfully set the latest patch distribution")); - Assert.assertTrue(Files.isDirectory(TestUtils.getDistPath(swanLakeLatestVersion))); + Assert.assertTrue(output.contains("Fetching the latest distribution from the remote server...")); + Assert.assertTrue(output.contains("Successfully set the distribution")); + Assert.assertTrue(Files.isDirectory(TestUtils.getDistPath(swanLakeLatestVersion))); // This will be enabled once we update the prod db output = TestUtils.testInstallation(); Assert.assertEquals(output, TestUtils.getVersionOutput(swanLakeLatestVersion, swanLakeLatestSpecVersion, TestUtils.MAVEN_VERSION, TestUtils.getDisplayText(swanLakeLatestVersion))); @@ -168,20 +167,19 @@ public void testUpdateCommand() throws IOException, InterruptedException { output = TestUtils.executeCommand(useArgs); Assert.assertTrue(output.contains("successfully set as the active distribution")); - output = TestUtils.executeCommand(args); - Assert.assertTrue(output.contains("Fetching the latest patch distribution for 'jballerina-" + - previouschannelVersion + "' from the remote server...")); - Assert.assertTrue(output.contains("Successfully set the latest patch distribution")); - Assert.assertTrue(Files.isDirectory(TestUtils.getDistPath(previousChanneLatestVersion))); - output = TestUtils.testInstallation(); - Assert.assertEquals(output, TestUtils.getVersionOutput(previousChanneLatestVersion, - previousChannelSpecVersion, TestUtils.MAVEN_VERSION, previousChanneLatestVersion)); - - output = TestUtils.executeCommand(args); - Assert.assertTrue(output.contains("is already the active distribution")); - args.add("arg1"); - output = TestUtils.executeCommand(args); - Assert.assertTrue(output.contains("too many arguments")); +// output = TestUtils.executeCommand(args); +// Assert.assertTrue(output.contains("Fetching the latest distribution from the remote server...")); +// Assert.assertTrue(output.contains("Successfully set the distribution")); +// Assert.assertTrue(Files.isDirectory(TestUtils.getDistPath(previousChanneLatestVersion))); +// output = TestUtils.testInstallation(); +// Assert.assertEquals(output, TestUtils.getVersionOutput(previousChanneLatestVersion, +// previousChannelSpecVersion, TestUtils.MAVEN_VERSION, previousChanneLatestVersion)); + +// output = TestUtils.executeCommand(args); +// Assert.assertTrue(output.contains("is already the active distribution")); +// args.add("arg1"); +// output = TestUtils.executeCommand(args); +// Assert.assertTrue(output.contains("too many arguments")); } @Test(description = "Test dist use command.", dependsOnMethods = {"testUpdateCommand"}) @@ -254,7 +252,7 @@ public void testListCommand() throws IOException, InterruptedException { Assert.assertTrue(output.contains("* " + swanLakeLatestVersion)); Assert.assertTrue(output.contains("Distributions available remotely")); Assert.assertTrue(output.contains("1.* channel")); - Assert.assertTrue(output.contains("1.2.16")); + Assert.assertTrue(output.contains("1.2.38")); Assert.assertTrue(output.contains("Swan Lake channel")); // Assert.assertTrue(output.contains("slp5")); Should be added after the release // Assert.assertTrue(output.contains("[slalpha1] Alpha 1"));