public inbox for cygwin-apps-cvs@sourceware.org
help / color / mirror / Atom feed
From: jturney@sourceware.org
To: cygwin-apps-cvs@sourceware.org
Subject: [setup - the official Cygwin setup program] branch master, updated. release_2.901-9-g0706ce81
Date: Wed, 26 Feb 2020 22:02:00 -0000	[thread overview]
Message-ID: <20200226220153.117623.qmail@sourceware.org> (raw)




https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=0706ce81165537f56814379b24290640d441de51

commit 0706ce81165537f56814379b24290640d441de51
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Mon Feb 24 19:25:43 2020 +0000

    Also AttachConsole() when not elevating
    
    Arrange to call AttachConsole() when not elevating (e.g. 'setup -B').
    
    This seems to be needed for output to stdout to work via a Windows
    pseudo-console ('conpty'), as is used with cygwin >=3.0.0.
    
    Note that setup is a GUI application. I have no idea what it means to
    write to stdout without calling AttachConsole(), but that doesn't seem
    to work anymore...

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=bdf30e6e5bc41babc5bab080fdd01231e6f8bf7a

commit bdf30e6e5bc41babc5bab080fdd01231e6f8bf7a
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Mon Feb 3 19:54:12 2020 +0000

    Fix 'make check'
    
    Add <string.h> where needed to fix compilation of libgetopt++ tests
    
    UserSetting was removed in f26f525f, so remove that test.
    
    UserSettings also got rewritten in that commit, so rewrite test.
    
    Rework UserSettings constructor so it can be initialized without needing
    to attempt loading from a file (which requires all the io_stream URL
    providers we might try to be registered).
    
    Run 'make check' in appveyor.


Diff:
---
 .appveyor.yml                       |  8 ++--
 UserSettings.cc                     | 10 ++++-
 UserSettings.h                      |  5 ++-
 libgetopt++/tests/BoolOptionTest.cc |  1 +
 libgetopt++/tests/OptionSet.cc      |  1 +
 main.cc                             |  9 ++--
 tests/Makefile.am                   | 28 ++++---------
 tests/UserSettingTest.cc            | 83 -------------------------------------
 tests/UserSettingsTest.cc           | 23 ++++------
 9 files changed, 39 insertions(+), 129 deletions(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index 9998cc6e..f5854d72 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -30,11 +30,13 @@ make,\
 pkg-config,\
 upx"
 build_script:
- - echo Bootstrap running...
+ - echo Bootstrap ...
  - '%CYGWIN_ROOT%/bin/bash -lc "cd $APPVEYOR_BUILD_FOLDER; ./bootstrap.sh --host=%HOST%"'
- - echo Make running...
+ - echo Make ...
  - '%CYGWIN_ROOT%/bin/bash -lc "cd $APPVEYOR_BUILD_FOLDER; make"'
- - echo Strip/UPX running...
+ - echo Tests ...
+ - '%CYGWIN_ROOT%/bin/bash -lc "cd $APPVEYOR_BUILD_FOLDER; export PATH=/usr/${HOST}/sys-root/mingw/bin/:${PATH} ; make check"'
+ - echo Strip/UPX ...
  - '%CYGWIN_ROOT%/bin/bash -lc "cd $APPVEYOR_BUILD_FOLDER; make strip upx"'
 cache: C:\cache
 test: off
diff --git a/UserSettings.cc b/UserSettings.cc
index b90d7958..d0bb4ef4 100644
--- a/UserSettings.cc
+++ b/UserSettings.cc
@@ -82,11 +82,17 @@ UserSettings::open_settings (const char *filename, std::string &pathname)
   return f;
 }
 
-UserSettings::UserSettings (std::string local_dir)
-  : table (NULL), table_len (-1), cwd (local_dir)
+UserSettings::UserSettings ()
+   : table (NULL), table_len (-1)
 {
   global = this;
   extend_table (0);
+}
+
+void
+UserSettings::load (std::string local_dir)
+{
+  cwd = local_dir;
   io_stream *f = open_settings ("setup.rc", filename);
 
   if (!f)
diff --git a/UserSettings.h b/UserSettings.h
index 8f661cb2..3de06e1d 100644
--- a/UserSettings.h
+++ b/UserSettings.h
@@ -31,14 +31,15 @@ private:
 
 public:
   static class UserSettings *global;
-  UserSettings (std::string);
+  UserSettings ();
   static UserSettings& instance() {return *global;}
 
   const char *get (const char *);
   unsigned int get_index (const char *key);
-  io_stream *open (const char *);
+  io_stream *open (const char *); // opens an iostream you can write to set the value of key
   const char *set (const char *, const char *);
   const char *set (const char *key, const std::string val) {return set (key, val.c_str ());}
+  void load (std::string local_dir);
   void save ();
 
 private:
diff --git a/libgetopt++/tests/BoolOptionTest.cc b/libgetopt++/tests/BoolOptionTest.cc
index 138d06da..d2c51909 100644
--- a/libgetopt++/tests/BoolOptionTest.cc
+++ b/libgetopt++/tests/BoolOptionTest.cc
@@ -18,6 +18,7 @@
 #include "getopt++/BoolOption.h"
 
 #include <iostream>
+#include <string.h>
 
 static BoolOption testoption (false, 't', "testoption", "Tests the use of boolean options");
 int
diff --git a/libgetopt++/tests/OptionSet.cc b/libgetopt++/tests/OptionSet.cc
index 8f2de24b..ff63e390 100644
--- a/libgetopt++/tests/OptionSet.cc
+++ b/libgetopt++/tests/OptionSet.cc
@@ -18,6 +18,7 @@
 #include "getopt++/StringOption.h"
 
 #include <iostream>
+#include <string.h>
 
 class StringCollector : public Option
 {
diff --git a/main.cc b/main.cc
index 5de1f360..b3854a84 100644
--- a/main.cc
+++ b/main.cc
@@ -263,9 +263,6 @@ WinMain (HINSTANCE h,
 
     bool output_only = help_option || VersionOption;
 
-    if (unattended_mode || output_only)
-      set_cout ();
-
     SetupBaseName = SetupBaseNameOpt;
     SetupArch = is_64bit ? "x86_64" : "x86";
     SetupIniDir = SetupArch+"/";
@@ -277,6 +274,9 @@ WinMain (HINSTANCE h,
     bool elevate = !output_only && OSMajorVersion () >= 6
 		   && !NoAdminOption && !nt_sec.isRunAsAdmin ();
 
+    if (unattended_mode || output_only || !elevate)
+      set_cout ();
+
     /* Start logging only if we don't elevate.  Same for setting default
        security settings. */
     LogSingleton::SetInstance (*LogFile::createLogFile ());
@@ -357,7 +357,8 @@ WinMain (HINSTANCE h,
 	/* Set default DACL and Group. */
 	nt_sec.setDefaultSecurity ((root_scope == IDC_ROOT_SYSTEM));
 
-	UserSettings Settings (local_dir);
+	UserSettings Settings;
+        UserSettings::instance().load (local_dir);
 	main_display ();
 	Settings.save ();	// Clean exit.. save user options.
 	if (rebootneeded)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 695e853e..7284e6b2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -14,35 +14,25 @@
 #
 # Makefile for Cygwin installer tests
 
-AUTOMAKE_OPTIONS = dist-bzip2 subdir-objects 1.6 foreign
-
 # We would like to use -Winline for C++ as well, but some STL code triggers
 # this warning. (Bug verified present in gcc-3.3)
 AM_CXXFLAGS	= -Werror -Wall -Wpointer-arith -Wcomments \
-  -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes
-AM_CFLAGS	= $(AM_CXXFLAGS) -Wmissing-declarations -Winline
+  -Wcast-align -Wwrite-strings
+AM_CFLAGS	= $(AM_CXXFLAGS) -Wmissing-declarations -Winline \
+  -Wstrict-prototypes -Wmissing-prototypes
 
 AM_CPPFLAGS = -I. -I$(srcdir) -I$(top_srcdir)
 
 check_PROGRAMS = \
-	UserSettingTest \
 	UserSettingsTest
-	
+
 TESTS = \
-	UserSettingTest \
 	UserSettingsTest
-	
-UserSettingTest_SOURCES = UserSettingTest.cc
-UserSettingTest_CXXFLAGS = -DASTEST
-UserSettingTest_LDADD = \
-	$(top_builddir)/Exception.o \
-	$(top_builddir)/UserSetting.o \
-	$(top_builddir)/UserSettings.o \
-	$(top_builddir)/String++.o
-	
-UserSettingsTest_SOURCES = UserSettingsTest.cc UserSettingTest.cc
+
+UserSettingsTest_SOURCES = UserSettingsTest.cc
 UserSettingsTest_LDADD = \
 	$(top_builddir)/Exception.o \
-	$(top_builddir)/UserSetting.o \
 	$(top_builddir)/UserSettings.o \
-	$(top_builddir)/String++.o
\ No newline at end of file
+	$(top_builddir)/String++.o \
+	$(top_builddir)/io_stream.o \
+	$(top_builddir)/LogSingleton.o
diff --git a/tests/UserSettingTest.cc b/tests/UserSettingTest.cc
deleted file mode 100644
index 1a0b2c31..00000000
--- a/tests/UserSettingTest.cc
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2003, Robert Collins
- *
- *     This program is free software; you can redistribute it and/or modify
- *     it under the terms of the GNU General Public License as published by
- *     the Free Software Foundation; either version 2 of the License, or
- *     (at your option) any later version.
- *
- *     A copy of the GNU General Public License can be found at
- *     http://www.gnu.org/
- *
- * Written by Robert Collins <rbtcollins@hotmail.com>
- *
- */
-
-#include "site.h"
-#include "win32.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <process.h>
-#include <algorithm>
-
-#include "LogSingleton.h"
-#include "io_stream.h"
-
-#include "port.h"
-#include "Exception.h"
-#include "UserSetting.h"
-#include "UserSettings.h"
-
-class TestSetting : public UserSetting {
-  public:
-  TestSetting();
-  static TestSetting &getInstance();
-  virtual void load();
-  virtual void save();
-  void testPassed();
-  private:
-  static TestSetting Instance;
-  bool loaded;
-  bool saved;
-};
-
-TestSetting &
-TestSetting::getInstance()
-{
- return Instance;
-}
-
-TestSetting TestSetting::Instance;
-
-TestSetting::TestSetting() : loaded(false), saved(false) {}
-
-void
-TestSetting::load()
-{
- loaded = true;
-}
-
-void
-TestSetting::save()
-{
- saved = true;
-}
-
-void
-TestSetting::testPassed()
-{
- if (saved)
- exit(1);
- if(loaded)
- exit(1);
-}
-
-#ifdef ASTEST
-int
-main (int argc, char **argv)
-{
-  TestSetting::getInstance().testPassed();
-  return 0;
-}
-#endif
diff --git a/tests/UserSettingsTest.cc b/tests/UserSettingsTest.cc
index e78c3991..817636e3 100644
--- a/tests/UserSettingsTest.cc
+++ b/tests/UserSettingsTest.cc
@@ -13,26 +13,17 @@
  *
  */
 
-#include "site.h"
-#include "win32.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <process.h>
-#include <algorithm>
-
-#include "LogSingleton.h"
-#include "io_stream.h"
-
-#include "port.h"
-#include "Exception.h"
-#include "UserSetting.h"
 #include "UserSettings.h"
 
+#include <assert.h>
+#include <string.h>
+
 int
 main (int argc, char **argv)
 {
-  UserSettings::Instance().loadAllSettings();
-  UserSettings::Instance().saveAllSettings();
+  UserSettings settings;
+  UserSettings& i = UserSettings::instance();
+  i.set("key", "value");
+  assert(strcmp(i.get("key"), "value") == 0);
   return 0;
 }


                 reply	other threads:[~2020-02-26 22:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200226220153.117623.qmail@sourceware.org \
    --to=jturney@sourceware.org \
    --cc=cygwin-apps-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).